Files
owncast/static/web/_next/static/chunks/5535.9affafb118f634c3.js
2022-11-30 00:09:35 +00:00

1 line
16 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5535],{54907:function(e,t,n){"use strict";n.d(t,{Z:function(){return S}});var a=n(87462),r=n(4942),i=n(18073),s=n(94184),o=n.n(s),c=n(74902),l=n(15671),d=n(43144),u=n(60136),p=n(33643),h=n(71002),m=n(50344),v=n(67294),f=n(96774),y=n.n(f),A=n(45987),g=n(62874),x=n(97685),b=v.forwardRef(function(e,t){var n,a=e.prefixCls,i=e.forceRender,s=e.className,c=e.style,l=e.children,d=e.isActive,u=e.role,p=v.useState(d||i),h=(0,x.Z)(p,2),m=h[0],f=h[1];return(v.useEffect(function(){(i||d)&&f(!0)},[i,d]),m)?v.createElement("div",{ref:t,className:o()("".concat(a,"-content"),(n={},(0,r.Z)(n,"".concat(a,"-content-active"),d),(0,r.Z)(n,"".concat(a,"-content-inactive"),!d),n),s),style:c,role:u},v.createElement("div",{className:"".concat(a,"-content-box")},l)):null});b.displayName="PanelContent";var C=["className","id","style","prefixCls","headerClass","children","isActive","destroyInactivePanel","accordion","forceRender","openMotion","extra","collapsible"],Z=function(e){(0,u.Z)(n,e);var t=(0,p.Z)(n);function n(){var e;(0,l.Z)(this,n);for(var a=arguments.length,r=Array(a),i=0;i<a;i++)r[i]=arguments[i];return(e=t.call.apply(t,[this].concat(r))).onItemClick=function(){var t=e.props,n=t.onItemClick,a=t.panelKey;"function"==typeof n&&n(a)},e.handleKeyPress=function(t){("Enter"===t.key||13===t.keyCode||13===t.which)&&e.onItemClick()},e.renderIcon=function(){var t=e.props,n=t.showArrow,a=t.expandIcon,r=t.prefixCls,i=t.collapsible;if(!n)return null;var s="function"==typeof a?a(e.props):v.createElement("i",{className:"arrow"});return s&&v.createElement("div",{className:"".concat(r,"-expand-icon"),onClick:"header"===i||"icon"===i?e.onItemClick:null},s)},e.renderTitle=function(){var t=e.props,n=t.header,a=t.prefixCls,r=t.collapsible;return v.createElement("span",{className:"".concat(a,"-header-text"),onClick:"header"===r?e.onItemClick:null},n)},e}return(0,d.Z)(n,[{key:"shouldComponentUpdate",value:function(e){return!y()(this.props,e)}},{key:"render",value:function(){var e,t,n=this.props,i=n.className,s=n.id,c=n.style,l=n.prefixCls,d=n.headerClass,u=n.children,p=n.isActive,h=n.destroyInactivePanel,m=n.accordion,f=n.forceRender,y=n.openMotion,x=n.extra,Z=n.collapsible,w=(0,A.Z)(n,C),N="disabled"===Z,E="header"===Z,j="icon"===Z,I=o()((e={},(0,r.Z)(e,"".concat(l,"-item"),!0),(0,r.Z)(e,"".concat(l,"-item-active"),p),(0,r.Z)(e,"".concat(l,"-item-disabled"),N),e),i),k={className:o()("".concat(l,"-header"),(t={},(0,r.Z)(t,d,d),(0,r.Z)(t,"".concat(l,"-header-collapsible-only"),E),(0,r.Z)(t,"".concat(l,"-icon-collapsible-only"),j),t)),"aria-expanded":p,"aria-disabled":N,onKeyPress:this.handleKeyPress};return E||j||(k.onClick=this.onItemClick,k.role=m?"tab":"button",k.tabIndex=N?-1:0),delete w.header,delete w.panelKey,delete w.onItemClick,delete w.showArrow,delete w.expandIcon,v.createElement("div",(0,a.Z)({},w,{className:I,style:c,id:s}),v.createElement("div",k,this.renderIcon(),this.renderTitle(),null!=x&&"boolean"!=typeof x&&v.createElement("div",{className:"".concat(l,"-extra")},x)),v.createElement(g.Z,(0,a.Z)({visible:p,leavedClassName:"".concat(l,"-content-hidden")},y,{forceRender:f,removeOnLeave:h}),function(e,t){var n=e.className,a=e.style;return v.createElement(b,{ref:t,prefixCls:l,className:n,style:a,isActive:p,forceRender:f,role:m?"tabpanel":null},u)}))}}]),n}(v.Component);function w(e){var t=e;if(!Array.isArray(t)){var n=(0,h.Z)(t);t="number"===n||"string"===n?[t]:[]}return t.map(function(e){return String(e)})}Z.defaultProps={showArrow:!0,isActive:!1,onItemClick:function(){},headerClass:"",forceRender:!1};var N=function(e){(0,u.Z)(n,e);var t=(0,p.Z)(n);function n(e){(0,l.Z)(this,n),(a=t.call(this,e)).onClickItem=function(e){var t=a.state.activeKey;if(a.props.accordion)t=t[0]===e?[]:[e];else{var n=(t=(0,c.Z)(t)).indexOf(e);n>-1?t.splice(n,1):t.push(e)}a.setActiveKey(t)},a.getNewChild=function(e,t){if(!e)return null;var n=a.state.activeKey,r=a.props,i=r.prefixCls,s=r.openMotion,o=r.accordion,c=r.destroyInactivePanel,l=r.expandIcon,d=r.collapsible,u=e.key||String(t),p=e.props,h=p.header,m=p.headerClass,f=p.destroyInactivePanel,y=p.collapsible,A=!1;A=o?n[0]===u:n.indexOf(u)>-1;var g=null!=y?y:d,x={key:u,panelKey:u,header:h,headerClass:m,isActive:A,prefixCls:i,destroyInactivePanel:null!=f?f:c,openMotion:s,accordion:o,children:e.props.children,onItemClick:"disabled"===g?null:a.onClickItem,expandIcon:l,collapsible:g};return"string"==typeof e.type?e:(Object.keys(x).forEach(function(e){void 0===x[e]&&delete x[e]}),v.cloneElement(e,x))},a.getItems=function(){var e=a.props.children;return(0,m.Z)(e).map(a.getNewChild)},a.setActiveKey=function(e){"activeKey"in a.props||a.setState({activeKey:e}),a.props.onChange(a.props.accordion?e[0]:e)};var a,r=e.activeKey,i=e.defaultActiveKey;return"activeKey"in e&&(i=r),a.state={activeKey:w(i)},a}return(0,d.Z)(n,[{key:"shouldComponentUpdate",value:function(e,t){return!y()(this.props,e)||!y()(this.state,t)}},{key:"render",value:function(){var e,t=this.props,n=t.prefixCls,a=t.className,i=t.style,s=t.accordion,c=o()((e={},(0,r.Z)(e,n,!0),(0,r.Z)(e,a,!!a),e));return v.createElement("div",{className:c,style:i,role:s?"tablist":null},this.getItems())}}],[{key:"getDerivedStateFromProps",value:function(e){var t={};return"activeKey"in e&&(t.activeKey=w(e.activeKey)),t}}]),n}(v.Component);N.defaultProps={prefixCls:"rc-collapse",onChange:function(){},accordion:!1,destroyInactivePanel:!1},N.Panel=Z,N.Panel;var E=n(98423),j=n(53124),I=n(33603),k=n(96159),O=function(e){var t,n,s=v.useContext(j.E_),c=s.getPrefixCls,l=s.direction,d=e.prefixCls,u=e.className,p=e.bordered,h=e.ghost,f=e.expandIconPosition,y=void 0===f?"start":f,A=c("collapse",d),g=v.useMemo(function(){return"left"===y?"start":"right"===y?"end":y},[y]),x=o()("".concat(A,"-icon-position-").concat(g),(n={},(0,r.Z)(n,"".concat(A,"-borderless"),!(void 0===p||p)),(0,r.Z)(n,"".concat(A,"-rtl"),"rtl"===l),(0,r.Z)(n,"".concat(A,"-ghost"),!!h),n),void 0===u?"":u),b=(0,a.Z)((0,a.Z)({},I.ZP),{motionAppear:!1,leavedClassName:"".concat(A,"-content-hidden")});return v.createElement(N,(0,a.Z)({openMotion:b},e,{expandIcon:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.expandIcon,a=n?n(t):v.createElement(i.Z,{rotate:t.isActive?90:void 0});return(0,k.Tm)(a,function(){return{className:o()(a.props.className,"".concat(A,"-arrow"))}})},prefixCls:A,className:x}),(t=e.children,(0,m.Z)(t).map(function(e,t){var n;if(null===(n=e.props)||void 0===n?void 0:n.disabled){var r=e.key||String(t),i=e.props,s=i.disabled,o=i.collapsible,c=(0,a.Z)((0,a.Z)({},(0,E.Z)(e.props,["disabled"])),{key:r,collapsible:null!=o?o:s?"disabled":void 0});return(0,k.Tm)(e,c)}return e})))};O.Panel=function(e){var t=v.useContext(j.E_).getPrefixCls,n=e.prefixCls,i=e.className,s=e.showArrow,c=t("collapse",n),l=o()((0,r.Z)({},"".concat(c,"-no-arrow"),!(void 0===s||s)),void 0===i?"":i);return v.createElement(N.Panel,(0,a.Z)({},e,{prefixCls:c,className:l}))};var S=O},11382:function(e,t,n){"use strict";var a=n(87462),r=n(4942),i=n(97685),s=n(94184),o=n.n(s),c=n(23279),l=n.n(c),d=n(98423),u=n(67294),p=n(53124),h=n(96159),m=n(93355),v=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&0>t.indexOf(a)&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,a=Object.getOwnPropertySymbols(e);r<a.length;r++)0>t.indexOf(a[r])&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]]);return n};(0,m.b)("small","default","large");var f=null,y=function(e){var t=e.spinPrefixCls,n=e.spinning,s=void 0===n||n,c=e.delay,m=e.className,y=e.size,A=void 0===y?"default":y,g=e.tip,x=e.wrapperClassName,b=e.style,C=e.children,Z=v(e,["spinPrefixCls","spinning","delay","className","size","tip","wrapperClassName","style","children"]),w=u.useState(function(){return s&&(!s||!c||!!isNaN(Number(c)))}),N=(0,i.Z)(w,2),E=N[0],j=N[1];return u.useEffect(function(){var e=l()(function(){j(s)},c);return e(),function(){var t;null===(t=null==e?void 0:e.cancel)||void 0===t||t.call(e)}},[c,s]),u.createElement(p.C,null,function(n){var i,s,c,l=n.direction,p=o()(t,(c={},(0,r.Z)(c,"".concat(t,"-sm"),"small"===A),(0,r.Z)(c,"".concat(t,"-lg"),"large"===A),(0,r.Z)(c,"".concat(t,"-spinning"),E),(0,r.Z)(c,"".concat(t,"-show-text"),!!g),(0,r.Z)(c,"".concat(t,"-rtl"),"rtl"===l),c),m),v=(0,d.Z)(Z,["indicator","prefixCls"]),y=u.createElement("div",(0,a.Z)({},v,{style:b,className:p,"aria-live":"polite","aria-busy":E}),(i=e.indicator,s="".concat(t,"-dot"),null===i?null:(0,h.l$)(i)?(0,h.Tm)(i,{className:o()(i.props.className,s)}):(0,h.l$)(f)?(0,h.Tm)(f,{className:o()(f.props.className,s)}):u.createElement("span",{className:o()(s,"".concat(t,"-dot-spin"))},u.createElement("i",{className:"".concat(t,"-dot-item")}),u.createElement("i",{className:"".concat(t,"-dot-item")}),u.createElement("i",{className:"".concat(t,"-dot-item")}),u.createElement("i",{className:"".concat(t,"-dot-item")}))),g?u.createElement("div",{className:"".concat(t,"-text")},g):null);if(void 0!==C){var w=o()("".concat(t,"-container"),(0,r.Z)({},"".concat(t,"-blur"),E));return u.createElement("div",(0,a.Z)({},v,{className:o()("".concat(t,"-nested-loading"),x)}),E&&u.createElement("div",{key:"loading"},y),u.createElement("div",{className:w,key:"container"},C))}return y})},A=function(e){var t=e.prefixCls,n=(0,u.useContext(p.E_).getPrefixCls)("spin",t),r=(0,a.Z)((0,a.Z)({},e),{spinPrefixCls:n});return u.createElement(y,(0,a.Z)({},r))};A.setDefaultIndicator=function(e){f=e},t.Z=A},65535:function(e,t,n){"use strict";n.r(t),n.d(t,{AuthModal:function(){return I}});var a=n(85893),r=n(90575),i=n(4480),s=n(8751),o=n(54907),c=n(84485),l=n(11382),d=n(26713),u=n(14670),p=n(69677),h=n(71577),m=n(67294),v=n(37174);let{Panel:f}=o.Z,{Link:y}=c.Z,A=e=>{let{authenticated:t,displayName:n,accessToken:r}=e,[i,c]=(0,m.useState)(null),[A,g]=(0,m.useState)(!1),[x,b]=(0,m.useState)(!1),[C,Z]=(0,m.useState)(""),w=t?(0,a.jsxs)("span",{children:[(0,a.jsx)("b",{children:"You are already authenticated"}),". However, you can add other domains or log in as a different user."]}):(0,a.jsxs)("span",{children:["Use your own domain to authenticate ",(0,a.jsx)("span",{children:n})," or login as a previously"," ","authenticated chat user using IndieAuth."]}),N=i;N&&N.includes("url does not support indieauth")&&(N="The provided URL is either invalid or does not support IndieAuth.");let E=e=>{if(!(0,v.Z)(e)||!e.includes(".")){b(!1);return}b(!0)},j=e=>{let t=e.nativeEvent.data;if(":"===t)return;Z(e.target.value);let n="https://".concat(e.target.value);E(n)},I=async()=>{if(x){g(!0);try{let e=await fetch("/api/auth/indieauth?accessToken=".concat(r),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({authHost:"https://".concat(C)})}),t=await e.json();if(t.message){c(t.message),g(!1);return}if(!t.redirect){c("Auth provider did not return a redirect URL."),g(!1);return}if(t.redirect){let{redirect:n}=t;window.location=n}}catch(a){c(a.message)}g(!1)}};return(0,a.jsx)(l.Z,{spinning:A,children:(0,a.jsxs)(d.Z,{direction:"vertical",children:[w,N&&(0,a.jsx)(u.Z,{message:"Error",description:N,type:"error",showIcon:!0}),(0,a.jsx)("div",{children:"Your domain"}),(0,a.jsx)(p.Z.Search,{addonBefore:"https://",onInput:j,type:"url",value:C,placeholder:"yoursite.com",status:!x&&C.length>0?"error":void 0,onSearch:I,enterButton:(0,a.jsx)(h.Z,{type:x?"primary":"default",disabled:!x||0===C.length,children:(0,a.jsx)(s.Z,{})})}),(0,a.jsx)(o.Z,{ghost:!0,children:(0,a.jsxs)(f,{header:"Learn more about using IndieAuth to authenticate with chat.",children:[(0,a.jsx)("p",{children:"IndieAuth allows for a completely independent and decentralized way of identifying yourself using your own domain."}),(0,a.jsxs)("p",{children:["If you run an Owncast instance, you can use that domain here. Otherwise,"," ",(0,a.jsx)(y,{href:"https://indieauth.net/#providers",children:"learn more about how you can support IndieAuth"}),"."]})]},"header")}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Note"}),": This is for authentication purposes only, and no personal information will be accessed or stored."]})]})})};var g=n(50501),x=n.n(g);let{Panel:b}=o.Z,C=e=>{let{authenticated:t,displayName:n,accessToken:r}=e,[i,c]=(0,m.useState)(null),[v,f]=(0,m.useState)(!1),[y,A]=(0,m.useState)(!1),[g,C]=(0,m.useState)(""),[Z,w]=(0,m.useState)(""),[N,E]=(0,m.useState)(!1),j=t?(0,a.jsxs)("span",{children:[(0,a.jsx)("b",{children:"You are already authenticated"}),". However, you can add other domains or log in as a different user."]}):(0,a.jsxs)("span",{children:["Receive a direct message on the Fediverse to link your account to"," ",(0,a.jsx)("strong",{children:n}),", or login as a previously linked chat user."]}),I=i;I&&I.includes("url does not support indieauth")&&(I="The provided URL is either invalid or does not support IndieAuth.");let k=e=>{A(function(e){let t=e.replace(/^@+/,"");return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(t).toLowerCase())}(e))},O=e=>{C(e.target.value),k(e.target.value)},S=async(e,t)=>{let n=await fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}),a=await n.json();a.message&&(c(a.message),f(!1))},P=async()=>{f(!0);try{await S("/api/auth/fediverse/verify?accessToken=".concat(r),{code:Z}),window.location.href="/"}catch(e){console.error(e),c(e)}f(!1)},T=async()=>{if(!y)return;f(!0),c(null);let e=g.replace(/^@+/,"");try{await S("/api/auth/fediverse?accessToken=".concat(r),{account:e}),E(!0)}catch(t){console.error(t),c(t)}f(!1)},R=(0,a.jsxs)("div",{children:["Paste in the code that was sent to your Fediverse account. If you did not receive a code, make sure you can accept direct messages.",(0,a.jsxs)("div",{className:x().codeInputContainer,children:[(0,a.jsx)(p.Z,{value:Z,onChange:e=>w(e.target.value),className:x().codeInput,placeholder:"123456",maxLength:6}),(0,a.jsx)(h.Z,{type:"primary",onClick:P,disabled:Z.length<6,className:x().submitButton,children:"Verify Code"})]})]}),M=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{children:"Your Fediverse Account"}),(0,a.jsx)(p.Z.Search,{addonBefore:"@",onInput:O,value:g,placeholder:"youraccount@yourserver.com",status:!y&&g.length>0?"error":void 0,onSearch:T,enterButton:(0,a.jsx)(h.Z,{type:y?"primary":"default",disabled:!y||0===g.length,children:(0,a.jsx)(s.Z,{})})})]});return(0,a.jsx)(l.Z,{spinning:v,children:(0,a.jsxs)(d.Z,{direction:"vertical",children:[j,I&&(0,a.jsx)(u.Z,{message:"Error",description:I,type:"error",showIcon:!0}),N?R:M,(0,a.jsx)(o.Z,{ghost:!0,children:(0,a.jsx)(b,{header:"Learn more about using the Fediverse to authenticate with chat.",children:(0,a.jsx)("p",{children:"xxxxxx"})},"header")}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"Note"}),": This is for authentication purposes only, and no personal information will be accessed or stored."]})]})})};var Z={src:"/_next/static/media/fediverse-black.0b51c805.png",height:100,width:100,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAOVBMVEVMaXEbGxsREREQEBAPDw8NDQ0FBQUQEBAQEBAUFBQNDQ0REREVFRUQEBAODg4UFBQUFBQHBwcNDQ1DUQGwAAAAE3RSTlMAC2QvWeDEnZQbSn15tW2ri/pAr8wTOgAAAAlwSFlzAAALEwAACxMBAJqcGAAAAD1JREFUeJwdy0cOgDAMAMGNS2yHFPj/Z0GcRwMwegNaWbgB3WfmZSArZd7eqR0qEYM6GT/pc/bygqal8v0XMgEBhHcrytIAAAAASUVORK5CYII=",blurWidth:8,blurHeight:8},w={src:"/_next/static/media/indieauth.38c52a3d.png",height:512,width:406,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAICAMAAADtGH4KAAAAJFBMVEU4ODg4ODg5OTk5OTk5OTk4ODg5OTk4ODg5OTk5OTk5OTk4ODiRUFfYAAAAC3RSTlMCFOuovTv1zI8wabTrOYwAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAsSURBVHicBcGFAQAwDMCg1Gb5/98BHG1gd2UQGeQwVvl4ujyUEzbbi8nyhn4bVgEfoFU38wAAAABJRU5ErkJggg==",blurWidth:6,blurHeight:8},N=n(54639),E=n.n(N),j=n(77466);let I=()=>{let e=(0,i.sJ)(j.L4),t=(0,i.sJ)(j.FI),n=(0,i.sJ)(j.db);if(!n)return null;let{displayName:s}=n,o=(0,a.jsxs)("span",{className:E().tabContent,children:[(0,a.jsx)("img",{className:E().icon,src:w.src,alt:"IndieAuth"}),"IndieAuth"]}),c=(0,a.jsx)(A,{authenticated:e,displayName:s,accessToken:t}),l=(0,a.jsxs)("span",{className:E().tabContent,children:[(0,a.jsx)("img",{className:E().icon,src:Z.src,alt:"Fediverse auth"}),"FediAuth"]}),d=(0,a.jsx)(C,{authenticated:e,displayName:s,accessToken:t});return(0,a.jsx)("div",{children:(0,a.jsx)(r.Z,{defaultActiveKey:"1",items:[{label:o,key:"1",children:c},{label:l,key:"2",children:d}],type:"card",size:"small",renderTabBar:null})})}},54639:function(e){e.exports={tabContent:"AuthModal_tabContent__KgMU3",icon:"AuthModal_icon__kpEuV"}},50501:function(e){e.exports={codeInputContainer:"FediAuthModal_codeInputContainer__M_dAD",codeInput:"FediAuthModal_codeInput__dIE6u",submitButton:"FediAuthModal_submitButton__iuF9R"}}}]);