openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 8.72 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Fu as t,Uu as n,Y as r,Z as i}from"./_4____________________________.js";import{GN as a,JN as o,qN as s}from"./_2_____________________________.js";import{B as c,U as l,d as u,f as d,j as f,u as p,x as m}from"./_6____________________.js";import{n as h,r as g}from"./en-preferences-BxI3BUpx.js";import{n as ee,t as te}from"./gateway-page-runtime-CW2orlv_.js";import{C as _,d as v,f as y,g as b,m as x,w as S,x as C,y as w}from"./settings-controls-runtime-CwXZmgDo.js";import{c as T,s as ne}from"./route-chrome-Dr9fhzjf.js";import{n as re,t as E}from"./tool-catalog-DSlK3gNp.js";function ie(e,r){if(r.authMode)return r.authMode;let i=n(n(e.gateway)?.auth);return t(i?.mode)||(i?.password?`password`:i?.token?`token`:i?.trustedProxy?`trusted-proxy`:`unknown`)}function D(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``);return t===`localhost`||t===`::1`||t.startsWith(`127.`)||t.endsWith(`.localhost`)}function O(e){return/^100\.(6[4-9]|[7-9]\d|1[01]\d|12[0-7])\./.test(e)||e.toLowerCase().startsWith(`fd7a:115c:a1e0:`)}function k(e,t,n){if(t===`funnel`)return{kind:`reportedFunnel`};if(t===`serve`)return{kind:`reportedServe`};if(D(e)){let e=n?.trim();return e&&!D(e)?{kind:`via`,host:e}:{kind:`reportedLoopback`}}return e===`0.0.0.0`||e===`::`?{kind:`reportedAllInterfaces`}:{kind:O(e)?`reportedTailnet`:`reportedHost`,host:e}}function A(e,r){if(r.bindHost&&r.tailscaleMode)return k(r.bindHost,r.tailscaleMode,r.connectedHost);if(r.configLoaded===!1)return{kind:`unknown`};let i=n(e.gateway),a=t(n(i?.tailscale)?.mode);if(a===`funnel`||a===`serve`)return{kind:a};let o=t(i?.bind);if(o===`custom`){let e=t(i?.customBindHost);return e?{kind:`custom`,host:e}:{kind:`auto`}}if(o===`lan`||o===`tailnet`||o===`auto`)return{kind:o};let s=r.connectedHost?.trim();return s&&!D(s)?{kind:`via`,host:s}:{kind:o===`loopback`?`loopback`:`default`}}function j(e,t,n){let r=e.indexOf(n);return r>=0&&r<e.indexOf(t)?n:t}function M(e,t){return I.indexOf(t)>I.indexOf(e)?t:e}function N(e,r){if(r.configLoaded===!1||!r.execApprovalDefaults)return`unknown`;let i=n(n(e.tools)?.exec)??{},a=t(i.mode)??``,o=R[a];if(a&&!o)return a;let s=o?.security??(t(i.security)||L.security),c=o?.ask??(t(i.ask)||L.ask),l=j(F,s,r.execApprovalDefaults.security),u=M(c,r.execApprovalDefaults.ask);return a&&l===s&&u===c?a:l===`deny`?`deny`:l===`allowlist`&&u===`off`?`allowlist`:l===`full`&&u!==`always`?`full`:F.includes(l)?`ask`:l}function P(e,t={}){let r=n(e.tools),i=n(e.browser),a=r?.profile;return{gatewayAuth:ie(e,t),gatewayAuthReported:!!(t.authMode&&t.bindHost&&t.tailscaleMode),networkAccess:A(e,t),execPolicy:N(e,t),browserEnabled:i?.enabled!==!1,toolProfile:typeof a==`string`?a.trim():``}}var F,I,L,R;function z(){return(z=e((()=>{F=[`deny`,`allowlist`,`full`],I=[`off`,`on-miss`,`always`],L={security:`full`,ask:`off`},R={deny:{security:`deny`,ask:`off`},allowlist:{security:`allowlist`,ask:`off`},ask:{security:`allowlist`,ask:`on-miss`},auto:{security:`allowlist`,ask:`on-miss`},full:{security:`full`,ask:`off`}}})))()}function B(e,t,n){return e.includes(n)?o(`quickSettings.security.${t}.${n}`):n}function V(e){switch(e.kind){case`unknown`:return;case`custom`:return o(`quickSettings.security.networkAccessDetail.configuredHost`,{host:e.host});case`via`:return o(`quickSettings.security.networkAccessDetail.via`,{host:e.host});case`reportedTailnet`:case`reportedHost`:return o(`quickSettings.security.networkAccessDetail.listening`,{host:e.host});case`reportedLoopback`:case`reportedAllInterfaces`:return;case`reportedServe`:case`reportedFunnel`:return o(`quickSettings.security.networkAccessDetail.${e.kind}`);default:return o(`quickSettings.security.networkAccessDetail.configured`)}}function H(e,t){return e.kind===`funnel`||e.kind===`reportedFunnel`?`warn`:e.kind===`reportedLoopback`?`ok`:e.kind===`unknown`||e.kind==="default"||e.kind===`loopback`?null:t===`none`?`warn`:e.kind===`reportedServe`||e.kind===`reportedTailnet`?`ok`:null}function U(e){let t=()=>B(X,`gatewayAuthValue`,e.security.gatewayAuth),n=()=>o(`quickSettings.security.networkAccessValue.${e.security.networkAccess.kind}`),r=()=>H(e.security.networkAccess,e.security.gatewayAuth);return f(b,{get title(){return o(`quickSettings.security.accessTitle`)},get children(){return[f(v,{get title(){return o(`quickSettings.security.gatewayAuth`)},get control(){return d(()=>e.security.gatewayAuth===`none`)()?f(w,{kind:`warn`,get label(){return t()}}):d(()=>!!e.security.gatewayAuthReported)()?f(w,{kind:`ok`,get label(){return t()}}):f(_,{get value(){return t()}})},onClick:()=>e.onOpenGatewaySettings?.()}),f(v,{get title(){return o(`quickSettings.security.networkAccess`)},get description(){return V(e.security.networkAccess)},get control(){return d(()=>!!r())()?f(w,{get kind(){return r()??`muted`},get label(){return n()}}):f(_,{get value(){return n()}})},onClick:()=>e.onOpenGatewaySettings?.()}),f(v,{get title(){return o(`tabs.devices`)},get description(){return o(`quickSettings.security.devicesDescription`)},onClick:()=>e.onOpenDevices?.()})]}})}function W(e){let t=()=>e.security.toolProfile,n=()=>E.some(e=>e.id===t()),r=()=>[{value:``,label:o(`quickSettings.security.toolProfileUnset`)},...E.map(e=>({value:e.id,label:o(e.labelKey)})),...t()&&!n()?[{value:t(),label:t()}]:[]],i=()=>o(`quickSettings.security.toolProfileDescription.${t()===``?`default`:n()?t():`custom`}`),a=()=>e.security.execPolicy;return f(b,{get title(){return o(`quickSettings.security.agentsTitle`)},get children(){return[f(v,{get title(){return o(`quickSettings.security.execPolicy`)},get description(){return d(()=>!!(Z.includes(a())&&a()!==`unknown`))()?o(`quickSettings.security.execPolicyDescription.${a()}`):void 0},get control(){return f(_,{get value(){return B(Z,`execPolicyValue`,a())}})},onClick:()=>e.onOpenDevices?.()}),f(x,{get title(){return o(`quickSettings.security.toolProfile`)},get description(){return i()},stackedOnNarrow:!0,get control(){return f(ne,{get"aria-label"(){return o(`quickSettings.security.toolProfile`)},get value(){return t()},get options(){return r()},get disabled(){return e.configBusy},onChange:t=>e.onToolProfileChange?.(t.currentTarget.value)})}}),f(C,{get title(){return o(`quickSettings.security.browserEnabled`)},get checked(){return e.security.browserEnabled},get disabled(){return e.configBusy},onChange:t=>e.onBrowserEnabledToggle?.(t)}),f(v,{get title(){return o(`tabs.approvals`)},get description(){return o(`quickSettings.security.approvalsDescription`)},onClick:()=>e.onOpenApprovals?.()})]}})}function G(e,t){return Q.has(e.join(`.`))?f(_,{get value(){return o(n(t)?.enabled===!0?`common.enabled`:`common.disabled`)}}):null}function K(e){var t=Y(),n=t.firstChild,r=n.nextSibling;return u(t,f(y,{get children(){return[f(U,e),f(W,e)]}}),n),u(t,()=>e.buildEditor({approvals:{label:o(`quickSettings.security.forwardingTitle`),summarizeObject:G},security:{label:o(`quickSettings.security.policiesTitle`),summarizeObject:G}}),r),t}function q(e){try{return e?new URL(e).hostname:null}catch{return null}}function J(e){let[t,n]=c(null,{ownedWrite:!0}),i=null,a=()=>{i=null,n(null)},o=ee({getGateway:()=>e.context.gateway,invalidateRequests:a,onSnapshot:({snapshot:e})=>{if(!r(e,`exec.approvals.get`,`operator.admin`)){a();return}if(i&&o.isCurrent(i))return;let t=o.capture();t&&(i=t,t.client.request(`exec.approvals.get`,{}).then(e=>{i===t&&o.isCurrent(t)&&r(o.snapshot,`exec.approvals.get`,`operator.admin`)&&n(e.resolvedDefaults??null)}).catch(()=>void 0))}});return f(K,{get security(){return P(e.configObject,{configLoaded:e.configLoaded,authMode:e.context.gateway.snapshot.hello?.snapshot?.authMode,connectedHost:q(e.gatewayUrl),bindHost:e.context.gateway.snapshot.hello?.snapshot?.bindHost,tailscaleMode:e.context.gateway.snapshot.hello?.snapshot?.tailscaleMode,execApprovalDefaults:t()})},get configBusy(){return e.configBusy},onOpenGatewaySettings:()=>e.context.navigate(`infrastructure`),onOpenDevices:()=>e.context.navigate(`devices`),onOpenApprovals:()=>e.context.navigate(`approvals`),onBrowserEnabledToggle:t=>t?e.context.runtimeConfig.removeFormValue([`browser`,`enabled`]):e.context.runtimeConfig.patchForm([`browser`,`enabled`],!1),onToolProfileChange:t=>t?e.context.runtimeConfig.patchForm([`tools`,`profile`],t):e.context.runtimeConfig.removeFormValue([`tools`,`profile`]),get buildEditor(){return e.buildEditor}})}var Y,X,Z,Q;function $(){return($=e((()=>{p(),l(),T(),S(),h(),re(),i(),te(),a(),z(),Y=m(`<section class=security-page><!><!>`),s(g),X=[`none`,`token`,`password`,`trusted-proxy`,`unknown`],Z=[`deny`,`allowlist`,`ask`,`auto`,`full`,`unknown`],Q=new Set([`approvals.exec`,`approvals.plugin`,`security.installPolicy`])})))()}$();export{K as Security,J as SecurityPage};