1 line
18 KiB
JavaScript
1 line
18 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9674],{54907:function(e,n,t){"use strict";t.d(n,{Z:function(){return _}});var a=t(87462),r=t(4942),i=t(18073),s=t(94184),o=t.n(s),c=t(74902),l=t(15671),u=t(43144),d=t(60136),p=t(33643),h=t(71002),v=t(67294),f=t(96774),m=t.n(f),y=t(50344),x=t(62874),g=t(97685),Z=v.forwardRef((function(e,n){var t,a=e.prefixCls,i=e.forceRender,s=e.className,c=e.style,l=e.children,u=e.isActive,d=e.role,p=v.useState(u||i),h=(0,g.Z)(p,2),f=h[0],m=h[1];return v.useEffect((function(){(i||u)&&m(!0)}),[i,u]),f?v.createElement("div",{ref:n,className:o()("".concat(a,"-content"),(t={},(0,r.Z)(t,"".concat(a,"-content-active"),u),(0,r.Z)(t,"".concat(a,"-content-inactive"),!u),t),s),style:c,role:d},v.createElement("div",{className:"".concat(a,"-content-box")},l)):null}));Z.displayName="PanelContent";var b=Z,C=function(e){(0,d.Z)(t,e);var n=(0,p.Z)(t);function t(){var e;(0,l.Z)(this,t);for(var a=arguments.length,r=new Array(a),i=0;i<a;i++)r[i]=arguments[i];return(e=n.call.apply(n,[this].concat(r))).onItemClick=function(){var n=e.props,t=n.onItemClick,a=n.panelKey;"function"===typeof t&&t(a)},e.handleKeyPress=function(n){"Enter"!==n.key&&13!==n.keyCode&&13!==n.which||e.onItemClick()},e.renderIcon=function(){var n=e.props,t=n.showArrow,a=n.expandIcon,r=n.prefixCls,i=n.collapsible;if(!t)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?e.onItemClick:null},s)},e.renderTitle=function(){var n=e.props,t=n.header,a=n.prefixCls,r=n.collapsible;return v.createElement("span",{className:"".concat(a,"-header-text"),onClick:"header"===r?e.onItemClick:null},t)},e}return(0,u.Z)(t,[{key:"shouldComponentUpdate",value:function(e){return!m()(this.props,e)}},{key:"render",value:function(){var e,n,t=this.props,i=t.className,s=t.id,c=t.style,l=t.prefixCls,u=t.headerClass,d=t.children,p=t.isActive,h=t.destroyInactivePanel,f=t.accordion,m=t.forceRender,y=t.openMotion,g=t.extra,Z=t.collapsible,C="disabled"===Z,N="header"===Z,j=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"),C),e),i),k={className:o()("".concat(l,"-header"),(n={},(0,r.Z)(n,u,u),(0,r.Z)(n,"".concat(l,"-header-collapsible-only"),N),n)),"aria-expanded":p,"aria-disabled":C,onKeyPress:this.handleKeyPress};N||(k.onClick=this.onItemClick,k.role=f?"tab":"button",k.tabIndex=C?-1:0);var w=null!==g&&void 0!==g&&"boolean"!==typeof g;return v.createElement("div",{className:j,style:c,id:s},v.createElement("div",k,this.renderIcon(),this.renderTitle(),w&&v.createElement("div",{className:"".concat(l,"-extra")},g)),v.createElement(x.Z,(0,a.Z)({visible:p,leavedClassName:"".concat(l,"-content-hidden")},y,{forceRender:m,removeOnLeave:h}),(function(e,n){var t=e.className,a=e.style;return v.createElement(b,{ref:n,prefixCls:l,className:t,style:a,isActive:p,forceRender:m,role:f?"tabpanel":null},d)})))}}]),t}(v.Component);C.defaultProps={showArrow:!0,isActive:!1,onItemClick:function(){},headerClass:"",forceRender:!1};var N=C;function j(e){var n=e;if(!Array.isArray(n)){var t=(0,h.Z)(n);n="number"===t||"string"===t?[n]:[]}return n.map((function(e){return String(e)}))}var k=function(e){(0,d.Z)(t,e);var n=(0,p.Z)(t);function t(e){var a;(0,l.Z)(this,t),(a=n.call(this,e)).onClickItem=function(e){var n=a.state.activeKey;if(a.props.accordion)n=n[0]===e?[]:[e];else{var t=(n=(0,c.Z)(n)).indexOf(e);t>-1?n.splice(t,1):n.push(e)}a.setActiveKey(n)},a.getNewChild=function(e,n){if(!e)return null;var t=a.state.activeKey,r=a.props,i=r.prefixCls,s=r.openMotion,o=r.accordion,c=r.destroyInactivePanel,l=r.expandIcon,u=r.collapsible,d=e.key||String(n),p=e.props,h=p.header,f=p.headerClass,m=p.destroyInactivePanel,y=p.collapsible,x=null!==y&&void 0!==y?y:u,g={key:d,panelKey:d,header:h,headerClass:f,isActive:o?t[0]===d:t.indexOf(d)>-1,prefixCls:i,destroyInactivePanel:null!==m&&void 0!==m?m:c,openMotion:s,accordion:o,children:e.props.children,onItemClick:"disabled"===x?null:a.onClickItem,expandIcon:l,collapsible:x};return"string"===typeof e.type?e:(Object.keys(g).forEach((function(e){"undefined"===typeof g[e]&&delete g[e]})),v.cloneElement(e,g))},a.getItems=function(){var e=a.props.children;return(0,y.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 r=e.activeKey,i=e.defaultActiveKey;return"activeKey"in e&&(i=r),a.state={activeKey:j(i)},a}return(0,u.Z)(t,[{key:"shouldComponentUpdate",value:function(e,n){return!m()(this.props,e)||!m()(this.state,n)}},{key:"render",value:function(){var e,n=this.props,t=n.prefixCls,a=n.className,i=n.style,s=n.accordion,c=o()((e={},(0,r.Z)(e,t,!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 n={};return"activeKey"in e&&(n.activeKey=j(e.activeKey)),n}}]),t}(v.Component);k.defaultProps={prefixCls:"rc-collapse",onChange:function(){},accordion:!1,destroyInactivePanel:!1},k.Panel=N;var w=k,I=(k.Panel,t(98423)),E=t(53124),S=t(33603),A=t(96159),P=function(e){var n,t=v.useContext(E.E_),s=t.getPrefixCls,c=t.direction,l=e.prefixCls,u=e.className,d=void 0===u?"":u,p=e.bordered,h=void 0===p||p,f=e.ghost,m=e.expandIconPosition,x=void 0===m?"start":m,g=s("collapse",l),Z=v.useMemo((function(){return"left"===x?"start":"right"===x?"end":x}),[x]),b=o()("".concat(g,"-icon-position-").concat(Z),(n={},(0,r.Z)(n,"".concat(g,"-borderless"),!h),(0,r.Z)(n,"".concat(g,"-rtl"),"rtl"===c),(0,r.Z)(n,"".concat(g,"-ghost"),!!f),n),d),C=(0,a.Z)((0,a.Z)({},S.ZP),{motionAppear:!1,leavedClassName:"".concat(g,"-content-hidden")});return v.createElement(w,(0,a.Z)({openMotion:C},e,{expandIcon:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.expandIcon,a=t?t(n):v.createElement(i.Z,{rotate:n.isActive?90:void 0});return(0,A.Tm)(a,(function(){return{className:o()(a.props.className,"".concat(g,"-arrow"))}}))},prefixCls:g,className:b}),function(){var n=e.children;return(0,y.Z)(n).map((function(e,n){var t;if(null===(t=e.props)||void 0===t?void 0:t.disabled){var r=e.key||String(n),i=e.props,s=i.disabled,o=i.collapsible,c=(0,a.Z)((0,a.Z)({},(0,I.Z)(e.props,["disabled"])),{key:r,collapsible:null!==o&&void 0!==o?o:s?"disabled":void 0});return(0,A.Tm)(e,c)}return e}))}())};P.Panel=function(e){var n=v.useContext(E.E_).getPrefixCls,t=e.prefixCls,i=e.className,s=void 0===i?"":i,c=e.showArrow,l=void 0===c||c,u=n("collapse",t),d=o()((0,r.Z)({},"".concat(u,"-no-arrow"),!l),s);return v.createElement(w.Panel,(0,a.Z)({},e,{prefixCls:u,className:d}))};var _=P},11382:function(e,n,t){"use strict";var a=t(87462),r=t(4942),i=t(15671),s=t(43144),o=t(60136),c=t(33643),l=t(94184),u=t.n(l),d=t(23279),p=t.n(d),h=t(98423),v=t(67294),f=t(53124),m=t(96159),y=t(93355),x=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)n.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(t[a[r]]=e[a[r]])}return t},g=((0,y.b)("small","default","large"),null);var Z=function(e){(0,o.Z)(t,e);var n=(0,c.Z)(t);function t(e){var s;(0,i.Z)(this,t),(s=n.call(this,e)).debouncifyUpdateSpinning=function(e){var n=(e||s.props).delay;n&&(s.cancelExistingSpin(),s.updateSpinning=p()(s.originalUpdateSpinning,n))},s.updateSpinning=function(){var e=s.props.spinning;s.state.spinning!==e&&s.setState({spinning:e})},s.renderSpin=function(e){var n,t=e.direction,i=s.props,o=i.spinPrefixCls,c=i.className,l=i.size,d=i.tip,p=i.wrapperClassName,f=i.style,y=x(i,["spinPrefixCls","className","size","tip","wrapperClassName","style"]),Z=s.state.spinning,b=u()(o,(n={},(0,r.Z)(n,"".concat(o,"-sm"),"small"===l),(0,r.Z)(n,"".concat(o,"-lg"),"large"===l),(0,r.Z)(n,"".concat(o,"-spinning"),Z),(0,r.Z)(n,"".concat(o,"-show-text"),!!d),(0,r.Z)(n,"".concat(o,"-rtl"),"rtl"===t),n),c),C=(0,h.Z)(y,["spinning","delay","indicator","prefixCls"]),N=v.createElement("div",(0,a.Z)({},C,{style:f,className:b,"aria-live":"polite","aria-busy":Z}),function(e,n){var t=n.indicator,a="".concat(e,"-dot");return null===t?null:(0,m.l$)(t)?(0,m.Tm)(t,{className:u()(t.props.className,a)}):(0,m.l$)(g)?(0,m.Tm)(g,{className:u()(g.props.className,a)}):v.createElement("span",{className:u()(a,"".concat(e,"-dot-spin"))},v.createElement("i",{className:"".concat(e,"-dot-item")}),v.createElement("i",{className:"".concat(e,"-dot-item")}),v.createElement("i",{className:"".concat(e,"-dot-item")}),v.createElement("i",{className:"".concat(e,"-dot-item")}))}(o,s.props),d?v.createElement("div",{className:"".concat(o,"-text")},d):null);if(s.isNestedPattern()){var j=u()("".concat(o,"-container"),(0,r.Z)({},"".concat(o,"-blur"),Z));return v.createElement("div",(0,a.Z)({},C,{className:u()("".concat(o,"-nested-loading"),p)}),Z&&v.createElement("div",{key:"loading"},N),v.createElement("div",{className:j,key:"container"},s.props.children))}return N};var o=e.spinning,c=function(e,n){return!!e&&!!n&&!isNaN(Number(n))}(o,e.delay);return s.state={spinning:o&&!c},s.originalUpdateSpinning=s.updateSpinning,s.debouncifyUpdateSpinning(e),s}return(0,s.Z)(t,[{key:"componentDidMount",value:function(){this.updateSpinning()}},{key:"componentDidUpdate",value:function(){this.debouncifyUpdateSpinning(),this.updateSpinning()}},{key:"componentWillUnmount",value:function(){this.cancelExistingSpin()}},{key:"cancelExistingSpin",value:function(){var e=this.updateSpinning;e&&e.cancel&&e.cancel()}},{key:"isNestedPattern",value:function(){return!(!this.props||"undefined"===typeof this.props.children)}},{key:"render",value:function(){return v.createElement(f.C,null,this.renderSpin)}}]),t}(v.Component);Z.defaultProps={spinning:!0,size:"default",wrapperClassName:""};var b=function(e){var n=e.prefixCls,t=(0,v.useContext(f.E_).getPrefixCls)("spin",n),r=(0,a.Z)((0,a.Z)({},e),{spinPrefixCls:t});return v.createElement(Z,(0,a.Z)({},r))};b.setDefaultIndicator=function(e){g=e},n.Z=b},9674:function(e,n,t){"use strict";t.r(n),t.d(n,{AuthModal:function(){return S}});var a=t(85893),r=t(2944),i=t(4480),s=t(47568),o=t(70655),c=t(54907),l=t(84485),u=t(11382),d=t(26713),p=t(14670),h=t(69677),v=t(71577),f=t(67294),m=t(19411),y=c.Z.Panel,x=l.Z.Link,g=function(e){var n=e.authenticated,t=e.displayName,r=e.accessToken,i=(0,f.useState)(null),l=i[0],g=i[1],Z=(0,f.useState)(!1),b=Z[0],C=Z[1],N=(0,f.useState)(!1),j=N[0],k=N[1],w=(0,f.useState)(""),I=w[0],E=w[1],S=n?(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:t})," or login as a previously"," ","authenticated chat user using IndieAuth."]}),A=l;A&&A.includes("url does not support indieauth")&&(A="The provided URL is either invalid or does not support IndieAuth.");var P=function(){var e=(0,s.Z)((function(){var e,n,t,a,i,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!j)return[2];C(!0),o.label=1;case 1:return o.trys.push([1,4,,5]),e="/api/auth/indieauth?accessToken=".concat(r),n="https://".concat(I),t={authHost:n},[4,fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)})];case 2:return[4,o.sent().json()];case 3:return(a=o.sent()).message?(g(a.message),C(!1),[2]):a.redirect?(a.redirect&&(i=a.redirect,window.location=i),[3,5]):(g("Auth provider did not return a redirect URL."),C(!1),[2]);case 4:return s=o.sent(),g(s.message),[3,5];case 5:return C(!1),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,a.jsx)(u.Z,{spinning:b,children:(0,a.jsxs)(d.Z,{direction:"vertical",children:[S,A&&(0,a.jsx)(p.Z,{message:"Error",description:A,type:"error",showIcon:!0}),(0,a.jsx)("div",{children:"Your domain"}),(0,a.jsx)(h.Z.Search,{addonBefore:"https://",onInput:function(e){if(":"!==e.nativeEvent.data){E(e.target.value);var n,t="https://".concat(e.target.value);n=t,(0,m.Z)(n)&&n.includes(".")?k(!0):k(!1)}},type:"url",value:I,placeholder:"yoursite.com",status:!j&&I.length>0?"error":void 0,onPressEnter:P,enterButton:(0,a.jsx)(v.Z,{onClick:P,disabled:!j,children:"Authenticate with your domain"})}),(0,a.jsx)(c.Z,{ghost:!0,children:(0,a.jsxs)(y,{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)(x,{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."]})]})})},Z=t(55237),b=t.n(Z);var C=c.Z.Panel,N=function(e){var n=e.authenticated,t=e.displayName,r=e.accessToken,i=(0,f.useState)(null),l=i[0],m=i[1],y=(0,f.useState)(!1),x=y[0],g=y[1],Z=(0,f.useState)(!1),N=Z[0],j=Z[1],k=(0,f.useState)(""),w=k[0],I=k[1],E=(0,f.useState)(""),S=E[0],A=E[1],P=(0,f.useState)(!1),_=P[0],T=P[1],K=n?(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:t}),", or login as a previously linked chat user."]}),O=l;O&&O.includes("url does not support indieauth")&&(O="The provided URL is either invalid or does not support IndieAuth.");var F=function(e){j(function(e){var n=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(n).toLowerCase())}(e))},M=function(){var e=(0,s.Z)((function(e,n){var t;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return[4,fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(n)})];case 1:return[4,a.sent().json()];case 2:return(t=a.sent()).message&&(m(t.message),g(!1)),[2]}}))}));return function(n,t){return e.apply(this,arguments)}}(),U=function(){var e=(0,s.Z)((function(){var e,n,t;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:g(!0),e="/api/auth/fediverse/verify?accessToken=".concat(r),n={code:S},a.label=1;case 1:return a.trys.push([1,3,,4]),[4,M(e,n)];case 2:return a.sent(),window.location.href="/",[3,4];case 3:return t=a.sent(),console.error(t),m(t),[3,4];case 4:return g(!1),[2]}}))}));return function(){return e.apply(this,arguments)}}(),R=function(){var e=(0,s.Z)((function(){var e,n,t,a;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if(!N)return[2];g(!0),m(null),e="/api/auth/fediverse?accessToken=".concat(r),n=w.replace(/^@+/,""),t={account:n},i.label=1;case 1:return i.trys.push([1,3,,4]),[4,M(e,t)];case 2:return i.sent(),T(!0),[3,4];case 3:return a=i.sent(),console.error(a),m(a),[3,4];case 4:return g(!1),[2]}}))}));return function(){return e.apply(this,arguments)}}(),L=(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:b().codeInputContainer,children:[(0,a.jsx)(h.Z,{value:S,onChange:function(e){return A(e.target.value)},className:b().codeInput,placeholder:"123456",maxLength:6}),(0,a.jsx)(v.Z,{type:"primary",onClick:U,disabled:S.length<6,className:b().submitButton,children:"Verify Code"})]})]}),B=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{children:"Your Fediverse Account"}),(0,a.jsx)(h.Z.Search,{addonBefore:"@",onInput:function(e){I(e.target.value),F(e.target.value)},value:w,placeholder:"youraccount@yourserver.com",status:!N&&w.length>0?"error":void 0,onPressEnter:R,enterButton:(0,a.jsx)(v.Z,{onClick:R,disabled:!N,children:"Authenticate with Fediverse"})})]});return(0,a.jsx)(u.Z,{spinning:x,children:(0,a.jsxs)(d.Z,{direction:"vertical",children:[K,O&&(0,a.jsx)(p.Z,{message:"Error",description:O,type:"error",showIcon:!0}),_?L:B,(0,a.jsx)(c.Z,{ghost:!0,children:(0,a.jsx)(C,{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."]})]})})},j="/_next/static/media/fediverse-black.0b51c805.png",k="/_next/static/media/indieauth.38c52a3d.png",w=t(67211),I=t.n(w),E=t(1899),S=function(){var e=(0,i.sJ)(E.db);if(!e)return null;var n=(0,i.sJ)(E.L4),t=(0,i.sJ)(E.FI),s=e.displayName,o=[{label:(0,a.jsxs)("span",{className:I().tabContent,children:[(0,a.jsx)("img",{className:I().icon,src:k,alt:"IndieAuth"}),"IndieAuth"]}),key:"1",children:(0,a.jsx)(g,{authenticated:n,displayName:s,accessToken:t})},{label:(0,a.jsxs)("span",{className:I().tabContent,children:[(0,a.jsx)("img",{className:I().icon,src:j,alt:"Fediverse auth"}),"FediAuth"]}),key:"2",children:(0,a.jsx)(N,{authenticated:n,displayName:s,accessToken:t})}];return(0,a.jsx)("div",{children:(0,a.jsx)(r.Z,{defaultActiveKey:"1",items:o,type:"card",size:"small",renderTabBar:null})})}},67211:function(e){e.exports={tabContent:"AuthModal_tabContent__KgMU3",icon:"AuthModal_icon__kpEuV"}},55237:function(e){e.exports={codeInputContainer:"FediAuthModal_codeInputContainer__M_dAD",codeInput:"FediAuthModal_codeInput__dIE6u",submitButton:"FediAuthModal_submitButton__iuF9R"}}}]); |