Files
owncast/static/web/_next/static/chunks/pages/admin/access-tokens-2e6306abb76ba060.js
T
2025-01-16 07:40:52 +00:00

1 line
7.9 KiB
JavaScript
Vendored

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9882],{26562:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/access-tokens",function(){return t(38126)}])},64773:function(e,n,t){"use strict";t.d(n,{Z:function(){return s}});var r=t(97685),c=t(67294);function s(){var e=c.useReducer(function(e){return e+1},0);return(0,r.Z)(e,2)[1]}},78021:function(e,n,t){"use strict";var r=t(78235);n.Z=r.Z},23061:function(e,n,t){"use strict";var r=t(67294),c=t(64773),s=t(98947);n.Z=function(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],n=(0,r.useRef)({}),t=(0,c.Z)();return(0,r.useEffect)(function(){var r=s.ZP.subscribe(function(r){n.current=r,e&&t()});return function(){return s.ZP.unsubscribe(r)}},[]),n.current}},65765:function(e,n,t){"use strict";var r=t(61185),c=t(59408),s=r.ZP;s.Header=r.h4,s.Footer=r.$_,s.Content=r.VY,s.Sider=c.Z,s._InternalSiderContext=c.D,n.default=s},10227:function(e,n,t){"use strict";var r=t(79338);n.Z=r.Z},91624:function(e,n,t){"use strict";t.d(n,{Z:function(){return x}});var r=t(4942),c=t(87462),s=t(97685),o=t(69156),a=t(93967),l=t.n(a),i=t(97485),u=t(67294),d=t(17399),f=t(22781),h=t(51964),p=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>n.indexOf(r)&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var c=0,r=Object.getOwnPropertySymbols(e);c<r.length;c++)0>n.indexOf(r[c])&&Object.prototype.propertyIsEnumerable.call(e,r[c])&&(t[r[c]]=e[r[c]]);return t},m=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>n.indexOf(r)&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var c=0,r=Object.getOwnPropertySymbols(e);c<r.length;c++)0>n.indexOf(r[c])&&Object.prototype.propertyIsEnumerable.call(e,r[c])&&(t[r[c]]=e[r[c]]);return t},y=new RegExp("^(".concat(f.Y.join("|"),")(-inverse)?$")),b=new RegExp("^(".concat(f.E.join("|"),")$")),v=u.forwardRef(function(e,n){var t=e.prefixCls,a=e.className,f=e.style,p=e.children,v=e.icon,x=e.color,k=e.onClose,j=e.closeIcon,C=e.closable,g=m(e,["prefixCls","className","style","children","icon","color","onClose","closeIcon","closable"]),Z=u.useContext(d.E_),w=Z.getPrefixCls,S=Z.direction,E=u.useState(!0),O=(0,s.Z)(E,2),_=O[0],N=O[1];u.useEffect(function(){"visible"in g&&N(g.visible)},[g.visible]);var P=function(){return!!x&&(y.test(x)||b.test(x))},T=(0,c.Z)({backgroundColor:x&&!P()?x:void 0},f),I=P(),A=w("tag",t),M=l()(A,(0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)({},"".concat(A,"-").concat(x),I),"".concat(A,"-has-color"),x&&!I),"".concat(A,"-hidden"),!_),"".concat(A,"-rtl"),"rtl"===S),a),R=function(e){e.stopPropagation(),null==k||k(e),!e.defaultPrevented&&("visible"in g||N(!1))},D="onClick"in g||p&&"a"===p.type,Q=(0,i.Z)(g,["visible"]),U=v||null,G=U?u.createElement(u.Fragment,null,U,u.createElement("span",null,p)):p,F=u.createElement("span",(0,c.Z)({},Q,{ref:n,className:M,style:T}),G,void 0!==C&&C?j?u.createElement("span",{className:"".concat(A,"-close-icon"),onClick:R},j):u.createElement(o.Z,{className:"".concat(A,"-close-icon"),onClick:R}):null);return D?u.createElement(h.Z,null,F):F});v.CheckableTag=function(e){var n=e.prefixCls,t=e.className,s=e.checked,o=e.onChange,a=e.onClick,i=p(e,["prefixCls","className","checked","onChange","onClick"]),f=(0,u.useContext(d.E_).getPrefixCls)("tag",n),h=l()(f,(0,r.Z)((0,r.Z)({},"".concat(f,"-checkable"),!0),"".concat(f,"-checkable-checked"),s),t);return u.createElement("span",(0,c.Z)({},i,{className:h,onClick:function(e){null==o||o(!s),null==a||a(e)}}))};var x=v},38126:function(e,n,t){"use strict";t.r(n);var r=t(85893),c=t(67294),s=t(23657),o=t(8968),a=t(91624),l=t(78021),i=t(72370),u=t(77786),d=t(20133),f=t(10227),h=t(56469),p=t(4116),m=t(27043),y=t(12642),b=t(5152),v=t.n(b),x=t(11992),k=t(25889);let{Title:j,Paragraph:C}=s.default,g=v()(()=>Promise.all([t.e(3247),t.e(1506)]).then(t.t.bind(t,81506,23)),{loadableGenerated:{webpack:()=>[81506]},ssr:!1}),Z={CAN_SEND_SYSTEM_MESSAGES:{name:"System messages",description:"Can send official messages on behalf of the system.",color:"purple"},CAN_SEND_MESSAGES:{name:"User chat messages",description:"Can send chat messages on behalf of the owner of this token.",color:"green"},HAS_ADMIN_ACCESS:{name:"Has admin access",description:"Can perform administrative actions such as moderation, get server statuses, etc.",color:"red"}},w=e=>{let{onOk:n,onCancel:t,open:s}=e,[o,a]=(0,c.useState)([]),[p,m]=(0,c.useState)(""),y=Object.keys(Z).map(e=>({value:e,label:Z[e].description})),b={disabled:0===o.length||""===p},v=y.map(e=>(0,r.jsx)(l.Z,{span:8,children:(0,r.jsx)(i.Z,{value:e.value,children:e.label})},e.value));return(0,r.jsxs)(u.default,{title:"Create New Access token",open:s,onOk:function(){n(p,o),a([]),m("")},onCancel:t,okButtonProps:b,children:[(0,r.jsxs)("p",{children:[(0,r.jsx)("p",{children:"The name will be displayed as the chat user when sending messages with this access token."}),(0,r.jsx)(d.default,{value:p,placeholder:"Name of bot, service, or integration",onChange:e=>m(e.currentTarget.value)})]}),(0,r.jsx)("p",{children:"Select the permissions this access token will have. It cannot be edited after it's created."}),(0,r.jsx)(i.Z.Group,{style:{width:"100%"},value:o,onChange:function(e){a(e)},children:(0,r.jsx)(f.Z,{children:v})}),(0,r.jsx)("p",{children:(0,r.jsx)(h.Z,{type:"primary",onClick:function(){a(Object.keys(Z))},children:"Select all"})})]})},S=()=>{let[e,n]=(0,c.useState)([]),[t,s]=(0,c.useState)(!1);function l(e){console.error("error",e)}async function i(){try{let e=await (0,x.rQ)(x.ms);n(e)}catch(e){l(e)}}async function u(e){try{await (0,x.rQ)(x.Wr,{method:"POST",data:{token:e}}),i()}catch(e){l(e)}}async function f(t,r){try{let c=await (0,x.rQ)(x.IO,{method:"POST",data:{name:t,scopes:r}});n(e.concat(c))}catch(e){l(e)}}(0,c.useEffect)(()=>{i()},[]);let b=[{title:"",key:"delete",render:(e,n)=>(0,r.jsx)(p.Z,{size:"middle",children:(0,r.jsx)(h.Z,{onClick:()=>u(n.accessToken),icon:(0,r.jsx)(g,{})})})},{title:"Name",dataIndex:"displayName",key:"displayName"},{title:"Token",dataIndex:"accessToken",key:"accessToken",render:e=>(0,r.jsx)(d.default.Password,{size:"small",bordered:!1,value:e})},{title:"Scopes",dataIndex:"scopes",key:"scopes",render:e=>(0,r.jsx)(r.Fragment,{children:e.map(e=>(function(e){if(!e||!Z[e])return null;let n=Z[e];return(0,r.jsx)(o.Z,{title:n.description,children:(0,r.jsx)(a.Z,{color:n.color,children:n.name})},e)})(e))})},{title:"Last Used",dataIndex:"lastUsed",key:"lastUsed",render:e=>{if(!e)return"Never";let n=new Date(e);return(0,y.WU)(n,"P p")}}];return(0,r.jsxs)("div",{children:[(0,r.jsx)(j,{children:"Access Tokens"}),(0,r.jsx)(C,{children:"Access tokens are used to allow external, 3rd party tools to perform specific actions on your Owncast server. They should be kept secure and never included in client code, instead they should be kept on a server that you control."}),(0,r.jsxs)(C,{children:["Read more about how to use these tokens, with examples, at"," ",(0,r.jsx)("a",{href:"https://owncast.online/docs/integrations/?source=admin",target:"_blank",rel:"noopener noreferrer",children:"our documentation"}),"."]}),(0,r.jsx)(m.Z,{rowKey:"token",columns:b,dataSource:e,pagination:!1}),(0,r.jsx)("br",{}),(0,r.jsx)(h.Z,{type:"primary",onClick:()=>{s(!0)},children:"Create Access Token"}),(0,r.jsx)(w,{open:t,onOk:(e,n)=>{s(!1),f(e,n)},onCancel:()=>{s(!1)}})]})};S.getLayout=function(e){return(0,r.jsx)(k.l,{page:e})},n.default=S},55945:function(e,n,t){"use strict";function r(e){return n=>{let t=(e?Math[e]:Math.trunc)(n);return 0===t?0:t}}t.d(n,{u:function(){return r}})},64077:function(e,n,t){"use strict";t.d(n,{_:function(){return c}});var r=t(46042);function c(e,n){return+(0,r.Q)(e)-+(0,r.Q)(n)}},94817:function(e,n,t){"use strict";t.d(n,{c:function(){return s}});var r=t(55945),c=t(64077);function s(e,n,t){let s=(0,c._)(e,n)/1e3;return(0,r.u)(null==t?void 0:t.roundingMethod)(s)}}},function(e){e.O(0,[83,1287,3800,7786,443,9904,3657,1175,2502,7528,9532,449,7043,4065,2642,5889,2888,9774,179],function(){return e(e.s=26562)}),_N_E=e.O()}]);