PageSourceSearch

https://app.evervault.com/assets/index-ClZypKBN.js

js evervault.com collected 2026-10-01 10:15:19 UTC 63,142 bytes, 21 lines download raw bytes

1import{dA as De,hB as I,e4 as Pt,dW as Ot,e$ as Be,g9 as Ge,ga as ye,eB as Vt,cu as Ut,iP as G,fR as e,b8 as W,bA as F,D as f,jn as ae,jx as it,js as $,iA as B,gA as x,es as rt,hR as _e,ja as Te,ac as b,c3 as A,aR as re,d$ as Se,G as ve,b_ as ue,cU as oe,er as $t,eq as zt,hD as P,cb as V,as as U,aT as Ht,jb as ge,iB as Q,iu as Wt,hk as K,gg as E,av as J,aF as le,gn as X,a_ as y,iF as Bt,k9 as Gt,hf as H,f$ as ot,dj as he,ef as Ve,hx as Z,g as ne,gf as N,hF as se,aj as lt,ik as Yt,iU as qt,jy as Zt,be as Qt,aN as ct,k7 as Kt,eu as Jt,ij as Xt,c0 as dt,fT as en,V as Ye,eA as tn,jw as ut,i8 as mt,ki as ht,cR as pt,ax as nn,Y as sn,bM as qe,iQ as an,bk as rn,aG as Ne,bK as on,bJ as ln,M as cn,bT as Ee,b$ as fe,jS as dn,cB as un,iV as gt,bd as Ce,aO as mn,bV as yt,H as hn,aX as xe,iD as pn,cd as gn,iT as yn,h as Ze,an as te,hP as fn,a1 as ft,Q as jt,cY as xt,iv as jn,hN as xn,ir as bn,bE as vn,bD as O,b2 as wn,b7 as kn}from"./index-CeTJDZ6L.js";import{H as ee}from"./index-CBE8JSI3.js";import{F as Dn,i as Ae,f as w,Y as _n,P as Sn,d as bt}from"./FunctionVersions.module-DS5PrWRm.js";import{u as vt}from"./useCopyToClipboard-CQWSqZBf.js";import{E as Ue}from"./external-link-DrcWb0w5.js";import{C as Le}from"./clipboard-CtsdSRfZ.js";import{T as $e}from"./trash-DOSP8az9.js";import{s as ze}from"./schemaResourceToDelete-Chhmsttb.js";import{S as Y}from"./SecondaryNavigation-BuMkVYiD.js";import{h as An,e as we,u as Fn,C as Nn,s as wt,p as kt,t as Qe,i as Dt}from"./queries-Cn2A2xII.js";import{C as _t}from"./index-Du0YT_35.js";import{J as En}from"./Javascript-KLtkXP8G.js";import{P as Cn}from"./Python-DaQ25Jqy.js";import{g as St,u as In}from"./useOAuth-9tPjmBsH.js";import{F as Mn}from"./fuse-Dw8P0qyA.js";import{e as Rn,E as Tn}from"./EmptyStateDiagram-Dt-OIfPI.js";import{E as Ln}from"./outbound-relay-empty-state-CBbIbMHq.js";import{E as Pn}from"./ellipsis-hPZ0P5UI.js";import{R as On}from"./rotate-cw-CM2i57Sm.js";import"./sub-DL6iFMmk.js";import"./subMonths-B6g_6Rnv.js";import"./useMediaQuery-D4Ea1rty.js";const Vn=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Un=De("code",Vn);const $n=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],zn=De("download",$n);const Hn=[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]],Wn=De("globe-lock",Hn);const Bn=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Gn=De("refresh-cw",Bn);function be(t,n){const s=I(t),a=I(n),r=s.getTime()-a.getTime();return r<0?-1:r>0?1:r}function Yn(t,n){const s=I(t),a=I(n),r=s.getFullYear()-a.getFullYear(),l=s.getMonth()-a.getMonth();return r*12+l}function qn(t){const n=I(t);return n.setHours(23,59,59,999),n}function Zn(t){const n=I(t);return+qn(n)==+Rn(n)}function Qn(t,n){const s=I(t),a=I(n),r=be(s,a),l=Math.abs(Yn(s,a));let u;if(l<1)u=0;else{s.getMonth()===1&&s.getDate()>27&&s.setDate(30),s.setMonth(s.getMonth()-r*l);let d=be(s,a)===-r;
1Zn(I(t))&&l===1&&be(t,a)===1&&(d=!1),u=r*(l-Number(d))}return u===0?0:u}function Kn(t,n,s){const a=Vt(),r=s?.locale??a.locale??Pt,l=2520,u=be(t,n);if(isNaN(u))throw new RangeError("Invalid time value");const d=Object.assign({},s,{addSuffix:s?.addSuffix,comparison:u});let m,i;u>0?(m=I(n),i=I(t)):(m=I(t),i=I(n));const c=Ot(i,m),h=(Be(i)-Be(m))/1e3,o=Math.round((c-h)/60);let p;if(o<2)return o===0?r.formatDistance("lessThanXMinutes",1,d):r.formatDistance("xMinutes",o,d);if(o<45)return r.formatDistance("xMinutes",o,d);if(o<90)return r.formatDistance("aboutXHours",1,d);if(o<Ge){const g=Math.round(o/60);return r.formatDistance("aboutXHours",g,d)}else{if(o<l)return r.formatDistance("xDays",1,d);if(o<ye){const g=Math.round(o/Ge);return r.formatDistance("xDays",g,d)}else if(o<ye*2)return p=Math.round(o/ye),r.formatDistance("aboutXMonths",p,d)}if(p=Qn(i,m),p<12){const g=Math.round(o/ye);return r.formatDistance("xMonths",g,d)}else{const g=p%12,v=Math.trunc(p/12);return g<3?r.formatDistance("aboutXYears",v,d):g<9?r.formatDistance("overXYears",v,d):r.formatDistance("almostXYears",v+1,d)}}var At=Ut(function(n,s,a){return a.replace(n,s)});function Jn({submissionHandler:t}){const{handleSubmit:n,formState:{isSubmitting:s}}=G();return e.jsxs("form",{onSubmit:n(a=>t(a)),children:[e.jsxs(W,{className:"mb-4",variant:"danger",children:[e.jsx(W.Title,{children:"This action cannot be undone"}),"This will delete this variable instantly."]}),e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{"data-testid":"submit-button",variant:"danger",loading:s}),children:"Delete variable"})]})}const ke=["EV_TEAM_UUID","EV_APP_UUID"],Xn=["LD_PRELOAD","EV_PARSE_DECRYPTED_STRINGS","EV_SHARD","EV_ALLOW_HTTP_REQUESTS","_HANDLER","_X_AMZN_TRACE_ID","AWS_REGION","AWS_EXECUTION_ENV","AWS_LAMBDA_FUNCTION_NAME","AWS_LAMBDA_FUNCTION_MEMORY_SIZE","AWS_LAMBDA_FUNCTION_VERSION","AWS_LAMBDA_INITIALIZATION_TYPE","AWS_LAMBDA_LOG_GROUP_NAME","AWS_LAMBDA_LOG_STREAM_NAME","AWS_ACCESS_KEY","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","AWS_LAMBDA_RUNTIME_API","LAMBDA_TASK_ROOT","LAMBDA_RUNTIME_DIR","TZ"],es=new Set([...ke,...Xn]),ts=(t,n,s)=>({mutationFn:({environmentVariables:a})=>oe.put($t(t,n,s),{json:{environmentVariables:a},timeout:6e4}).json()}),ns=(t,n,s)=>({mutationFn:a=>oe.delete(zt(t,n,s,a),{timeout:6e4}).json()}),ss=()=>{const{functionData:t}=ae(),n=it(),{teamUuid:s,appUuid:a}=$(),{uuid:r,environmentVariables:l,latestDeployment:u}=t,d=B(),[m,i]=x.useState(null),[c,h]=x.useState(!["deployed","failed","cancelled"].includes(u?.status)),o=rt.func(s,a,r),{enabled:p}=_e("superuser"),g=!t.disabled||p,{mutateAsync:v,isLoading:M}=Te({...ts(s,a,r),onMutate:async({environmentVariables:j})=>{h(!0),await n.cancelQueries({queryKey:o});const k=n.getQueryData(o),T=j.reduce((Lt,Fe)=>({...Lt,[Fe.environmentVariableKey]:Fe.isSecret?"••••••••••••••":Fe.environmentVariableValue}),k.environmentVariables);return n.setQueryData(o,{...k,environmentVariables:T}),{prevFunc:k}},onError(j,k,{prevFunc:T}){h(!1),n.setQueryData(o,T)},onSettled:async()=>{h(!1),await n.invalidateQueries({queryKey:o})}}),{mutateAsync:R}=Te({...ns(s,a,r),onMutate:async j=>{h(!0);const k=n.getQueryData(o),T=Object.assign({},k.environmentVariables);return delete T[j],n.setQueryData(o,{...k,environmentVariables:{...T}}),{prevFunc:k,deletedEnvKey:j}},onError:(j,k,T)=>{h(!1),n.setQueryData(o,T.prevFunc)},onSettled:async()=>{h(!1),await n.invalidateQueries({queryKey:o})}}),L=(l?Object.keys(l).map(j=>({key:j,value:l[j]})):[]).sort((j,k)=>ke.indexOf(k.key)-ke.indexOf(j.key)||j.key.localeCompare(k.key)),S=async j=>{try{d.close(),await R(j),P("Environment variable removed",{id:`env-var-remove-${j}`})}catch(k){k.code==="deployment-in-progress"?P.warning("Cannot update variables while deploying"):P.error(k.message||"Failed to remove variable")}},C=async({environmentVariables:j},{reset:k})=>{try{k(),await v({environmentVariables:j})}catch(T){T.code==="deployment-in-progress"?P.warning("Cannot update variables while deploying"):T.code==="forbidden-env-variable"?P.error("Forbidden environment variable name provided"):P.error(T.message||"Failed to add variables")}
1},ce=j=>{i(j.key),d.open()};return e.jsxs(e.Fragment,{children:[e.jsxs(b,{state:d,children:[e.jsx(b.Header,{title:"Delete variable"}),e.jsx(b.Body,{children:m&&e.jsx(Jn,{submissionHandler:()=>S(m)})})]}),e.jsx(ee,{title:"Environment Variables",text:e.jsx(e.Fragment,{children:e.jsxs(A,{leading:"md",className:"mb-2",children:["You can use environment variables to securely store secrets and use them in your Functions. Updates will automatically redeploy your Function and can take up to 30 seconds."," ",e.jsxs(re,{external:!0,href:Se("/functions#environment-variables"),children:["Learn More",e.jsx(Ue,{})]})]})})}),g&&e.jsx("div",{className:"mb-6",children:e.jsx(Dn,{onSubmit:C,disableSaving:c,disableSavingReason:"Please wait for previous deployment to finish",isLoading:M,reservedVariables:es})}),e.jsx(ve,{children:e.jsxs(ue,{"data-testid":"environmentVariables",headings:["Name","Value"],widths:["50%","50%"],children:[!L.length===0&&e.jsx(ue.Loading,{}),L.map(j=>e.jsx(as,{envVar:j,isDeploying:c,onDelete:()=>ce(j)},j.uuid))]})})]})};function as({envVar:t,isDeploying:n,onDelete:s}){const a=ke.includes(t.key),{copy:r,copied:l}=vt(),u=t.value.replace(/•/g,"").length===0;return e.jsxs(ue.Row,{children:[e.jsx(ue.Cell,{truncate:!0,children:e.jsx(V,{content:a?"Reserved variable":null,children:e.jsxs(U,{gap:8,align:"center",children:[a&&e.jsx(Ht,{size:14,style:{fill:"none"}}),e.jsx(A,{truncate:!0,children:t.key})]})})}),e.jsx(ue.Cell,{truncate:!0,children:e.jsxs(U,{justify:"between",align:"center",gap:12,children:[e.jsx(A,{truncate:!0,children:t.value}),e.jsxs(U,{gap:8,children:[!u&&e.jsx(V,{closeOnActive:!1,content:l?"Copied to clipboard":t.value,wordbreak:!0,children:e.jsx(f,{size:"xs","aria-label":"View environment variable",onClick:()=>r(t.value),children:e.jsx(Le,{})})}),e.jsx(V,{allowNesting:!1,content:a?"Reserved variable cannot be removed":n?"Please wait for previous deployment to finish":void 0,children:e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{size:"xs",variant:"danger","aria-label":`Delete ${t.key}`,onClick:s,disabled:a||n}),children:e.jsx($e,{"aria-hidden":!0})})})]})]})})]})}const is=t=>X({name:ze(t,{nonempty_error:"Enter your Function name to delete it",invalid_value_error:`Must match ${t} exactly`})}),rs=({loading:t,onFormSubmit:n,func:s})=>{const a=ge(),r=Q(),{teamUuid:l,appUuid:u}=$(),{mutateAsync:d}=Wt(),{register:m,handleSubmit:i,formState:{isSubmitting:c,errors:h}}=G({mode:"onTouched",defaultValues:{name:""},resolver:K(is(s.name))}),o=i(n||(async()=>{try{await d(s.uuid),a(`/${l}/${u}/functions`),E("Function deleted"),r.close()}catch(p){E.error(p.message||"Failed to delete function",{id:`delete-function-error-${s.uuid}`})}}));return e.jsxs("form",{onSubmit:o,"data-testid":"form-delete-function",children:[e.jsxs(W,{className:"mb-4",variant:"danger",children:[e.jsx(W.Title,{children:"This action cannot be undone"}),"This will delete this Function instantly. All requests to it will no longer work."]}),e.jsx(J,{className:"mb-4",label:e.jsxs(e.Fragment,{children:["Please type ",e.jsx("b",{children:s.name})," to confirm"]}),error:h?.name?.message,children:e.jsx(le,{...m("name",{disabled:t}),placeholder:s.name,"data-testid":"function-form-name","data-1p-ignore":!0})}),e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{"data-testid":"submit-button",variant:"danger",loading:t||c,disabled:!Ae(h)}),children:"Delete Function"})]})};function os({func:t}){const n=B();return e.jsxs(e.Fragment,{children:[e.jsxs(b,{state:n,children:[e.jsx(b.Header,{title:"Delete Function"}),e.jsx(b.Body,{children:e.jsx(rs,{"data-testid":"form-delete-function",func:t})})]}),e.jsx(ee,{title:"Danger Zone",variant:"danger"}),e.jsx(y,{children:e.jsxs(y.Row,{children:[e.jsx(y.Data,{children:e.jsx("h6",{children:"Delete Function"})}),e.jsx(y.Action,{children:e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{size:"sm",variant:"danger",onClick:n.open}),children:"Delete Function"})})]})})]})}const ls=()=>X({name:H().trim().regex(/^[A-Za-z0-9][-_\]?[A-Za-z0-9]*$/,{message:"Only alphanumeric characters, dashes, or underscores are allowed"}).min(2,"Function names must be at least 2 characters long").max(100,"Function names cannot be longer than 100 characters"),subdirectory:H().regex(/^(\.\/)?([A-Za-z0-9-_+]+\/?)*$/,{message:"The subdirectory must be a valid file path."}).optional().or(ot("")),branch:H().optional()}
1),cs=({name:t="",loading:n,onFormSubmit:s,func:a})=>{const[r,l]=x.useState(!1),u=ge(),d=Q(),{teamUuid:m,appUuid:i}=$(),c={name:a.name||"",branch:a.githubRepo?.branch||"",subdirectory:a.githubRepo?.directory},{mutateAsync:h}=Bt(),{register:o,handleSubmit:p,control:g,formState:{isSubmitting:v,errors:M}}=G({mode:"onTouched",defaultValues:c,resolver:K(ls())}),R=Gt({control:g,name:["branch","subdirectory"],defaultValue:!0});x.useEffect(()=>{const S=R.branch!==c.branch,C=R.subdirectory!==c.subdirectory;l(S||C)},[R]);const L=p(s||(async S=>{try{const C=S.subdirectory?.replace(/^\.\//,"");await h({funcUuid:a.uuid,funcData:{name:S.name,branch:S.branch,subdirectory:C}}),E.success("Function updated"),u(`/${m}/${i}/functions/${S.name}/general`),d.close()}catch(C){E.error(C.message||"Failed to update function",{id:`update-function-error-${a.uuid}`})}}));return e.jsxs("form",{onSubmit:L,"data-testid":"form-edit-function",children:[e.jsx(J,{className:"mb-4",label:"Name",error:M?.name?.message,children:e.jsx(le,{...o("name",{disabled:n}),placeholder:t||"myCoolFunction","data-testid":"function-form-name","data-1p-ignore":!0})}),e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{"data-testid":"submit-button",variant:"primary",loading:n||v,disabled:!Ae(M)}),children:r?"Update Function & Deploy":"Update Function"})]})},Ft=t=>t==="deployed",Nt=t=>["retrying","creatingRepo","uploadingTemplate","importingRepo","startingBuild","initiated","uploading","packaging","queuedForBuilding","building","provisioning"].includes(t),Et=t=>t==="cancelled",He=t=>t==="failed",ds=t=>He(t)?"Failed":Ft(t)?"Deployed":Et(t)?"Cancelled":"Deploying";function Ct({deployment:t}){return e.jsx("div",{className:he(w.versionStatus,{[w.versionStatusFailed]:He(t.status),[w.versionStatusDeployed]:Ft(t.status),[w.versionStatusCancelled]:Et(t.status)}),children:ds(t.status)})}const It={"node@16":new Date("2023-09-11")},us={year:"numeric",month:"short",day:"numeric"},Pe=t=>Ve.capitalizeFirstLetter(At("@"," ",t)),ms=t=>{if(t?.latestDeployment?.language)return Pe(t?.latestDeployment?.language);const n=t?.latestDeployment?.status;return n==="failed"||n==="cancelled"?"Failed to detect":"Detecting language and version..."},hs=t=>{const n=It[t?.latestDeployment?.language];return n>new Date?`${Pe(t?.latestDeployment?.language)} will be deprecated on ${n.toLocaleDateString("en-ie",us)}. Please upgrade to a newer version in your function.toml.`:`${Pe(t?.latestDeployment?.language)} is deprecated. To deploy please upgrade to a newer version in your function.toml.`},ps=t=>!!It[t?.latestDeployment?.language],me=t=>{const n=t.status;return t.deployedAt?Ve.capitalizeFirstLetter(Z(t.deployedAt).fromNow()):n==="failed"||n==="cancelled"?t.failureReason??"An unknown error occurred.":gs[n]||"Initiating Function..."},gs={initiated:"Function build initiated...",packaging:"Packaging Function code...",building:"Building Function...",provisioning:"Provisioning Function infrastructure...",retrying:"Restarting your build...",creatingRepo:"Creating a new repo...",uploadingTemplate:"Uploading your Function template...",importingRepo:"Importing your repository...",startingBuild:"Starting the build...",queuedForBuilding:"Other deployment in progress. Added to the queue...",cancelled:"User cancelled deployment.",failed:"Deployment failed.",deployed:"Deployed successfully."},Ie={initial:{y:4,opacity:0},animate:{y:0,opacity:1},exit:{y:-4,opacity:0}},ys=()=>{const{functionData:t}=ae(),n=ge(),{uuid:s,name:a,createdAt:r,githubRepo:l}=t,{copy:u}=vt(),d=B(),{enabled:m}=_e("superuser"),i=!t.disabled||m,c=({directory:M,url:R,branch:z})=>M!=="/"?`${R}/tree/${z}/${M}`:R,h=()=>window.open(`https://github.com/apps/${lt.github.appName}/installations/new`,"installEvervaultWindow","height=700, width=800"),o=()=>{n("../versions")},p=`https://api.evervault.com/functions/${a}/runs`,g=()=>{u(a),E(`Copied "${a}"`,{id:`copy-name-${a}`})},v=()=>{u(p),E("Copied function run endpoint",{id:`copy-function-run-endpoint-${a}`})};return e.jsxs(e.Fragment,{children:[e.jsxs(b,{state:d,children:[e.jsx(b.Header,{title:"Edit Function"}),e.jsx(b.Body,{children:e.jsx(cs,{"data-testid":"form-edit-function",func:t})})]}),e.jsx(ee,{title:"Function Info",actions:i&&e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{size:"sm",onClick:d.open,"data-testid":"edit-function-button"}),children:"Edit Function"})}),e.jsxs(y,{className:"mb-5",children:[l?.disabled&&e.jsxs(y.Row,{isWarning:!0,children:[e.jsxs(y.Data,{children:["The Evervault GitHub app has been uninstalled from this repository."," "]}),e.jsx(y.Action,{children:e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{size:"sm",onClick:h,"data-testid":"reauthenticate-github-button"}),children:"Configure GitHub"})})]}),e.jsxs(y.Row,{showActionOnHover:!0,children:[e.jsxs(y.Data,{children:[e.jsx("h6",{children:"Function name"}),e.jsx("p",{children:a})]}),e.jsx(y.Action,{children:e.jsx(V,{content:"Copy Function name",closeOnActive:!0,children:e.jsx(f,{size:"sm",onClick:g,"aria-label":"Copy Function Name",children:e.jsx(Le,{})})})})]}),e.jsx(y.Row,{children:e.jsxs(y.Data,{children:[e.jsx("h6",{children:"Function ID"}),e.jsx("p",{children:s})]})}),e.jsxs(y.Row,{showActionOnHover:!0,children:[e.jsxs(y.Data,{children:[e.jsx("h6",{children:"Function run endpoint"}),e.jsx("p",{children:p})]}),e.jsx(y.Action,{children:e.jsx(V,{content:"Copy function run endpoint",closeOnActive:!0,children:e.jsx(f,{size:"sm",onClick:v,"aria-label":"Copy function run endpoint",children:e.jsx(Le,{})})})})]}),e.jsx(y.Row,{children:e.jsxs(y.Data,{children:[e.jsx("h6",{children:"Language"}),e.jsx("p",{children:ms(t)}),ps(t)&&e.jsx(W,{className:"mt-2 mb-1",variant:"warning",children:hs(t)})]})}),e.jsx(y.Row,{children:e.jsxs(y.Data,{children:[e.jsx("h6",{children:"Created"}),e.jsx("p",{"data-testid":"created-stamp",title:Z(r).format("MMMM DD, YYYY, hh:mm a"),
1children:Ve.capitalizeFirstLetter(Z(r).fromNow())})]})}),t.latestDeployment&&e.jsxs(y.Row,{onClick:o,children:[e.jsxs(y.Data,{children:[e.jsx("h6",{children:"Last published"}),e.jsx("p",{"data-testid":"last-deployed-stamp",children:e.jsx(ne,{mode:"wait",initial:!1,children:e.jsx(V,{content:t.error?t.errorMessage||"Please check your code and try again.":null,children:e.jsx(N.span,{className:"d-inline-block",...Ie,children:me(t.latestDeployment)},me(t.latestDeployment))})})})]}),Nt(t.latestDeployment?.status)&&e.jsx(Ct,{deployment:t.latestDeployment})]}),t.disabled&&e.jsx(y.Row,{children:e.jsxs(y.Data,{children:[e.jsx("h6",{children:"Locked Function"}),e.jsx("p",{children:"This Function was deployed from an Evervault repository and cannot be updated"})]})}),l&&i&&e.jsxs(e.Fragment,{children:[e.jsx(y.Row,{children:e.jsxs(y.Data,{children:[e.jsx("h6",{children:"GitHub repository"}),e.jsx("p",{style:{minHeight:"1.2rem"},children:e.jsxs(ne,{mode:"wait",initial:!1,children:[!l?.url&&e.jsx(N.span,{className:"d-inline-block",...Ie,children:e.jsx(N.span,{...se.pulse,children:"Creating GitHub repository…"})},"gh-repo-init"),l?.url&&e.jsx(N.a,{href:l.url,className:"d-inline-block","data-testid":"github-stamp",target:"_blank",rel:"noreferrer",...Ie,children:At("https://github.com/","",l?.url)},"gh-repo-url")]})})]})}),l&&l.directory!=="/"&&e.jsx(y.Row,{children:e.jsxs(y.Data,{children:[e.jsx("h6",{children:"Directory"}),e.jsx("p",{title:`We'll redeploy your Function everytime changes are pushed which effect files in ${l.directory}`,children:e.jsx("a",{href:c(l),className:"d-inline-block",target:"_blank",rel:"noreferrer",children:l.directory},"gh-repo-directory-url")})]})})]})]})]})};function fs(){const{functionData:t}=ae();return e.jsxs(e.Fragment,{children:[e.jsx(ys,{}),!t.disabled&&e.jsx(os,{func:t})]})}function js({functions:t}){const n=Yt(),{teamUuid:s,appUuid:a,functionName:r}=$(),l=t.find(m=>m.name===r).uuid,{data:u}=qt(l,{suspense:!0}),d=Zt();return u&&d.add({type:"function",id:u.uuid}),e.jsxs(U,{gap:"32px",children:[e.jsx(U.Item,{children:e.jsxs(Y,{children:[e.jsx(Y.Link,{to:"general",children:"General"}),e.jsx(Y.Link,{to:"versions",children:"Versions"}),e.jsx(Y.Link,{to:"environment-variables",children:"Environment Variables"}),e.jsx(Y.Link,{to:"inbound-whitelist",children:"Inbound Whitelist"}),n.egressWhitelistingEnabled&&e.jsx(Y.Link,{to:"outbound-whitelist",children:"Outbound Whitelist"}),e.jsx(Y.Link,{to:"playground",children:"Playground"}),e.jsx(Y.Link,{to:{pathname:`/${s}/${a}/logs`,search:`?query=resource.id=${l}`},children:"Logs"})]})}),e.jsx(U.Item,{shrink:!0,grow:!0,children:e.jsx(x.Suspense,{fallback:e.jsx(ct.Loader,{}),children:e.jsx(Qt,{context:{functionData:u}})})})]})}const xs="_codeWrapper_1ebg3_1",bs="_label_1ebg3_9",vs="_labelClickable_1ebg3_17",ws="_code_1ebg3_1",ie={codeWrapper:xs,label:bs,labelClickable:vs,code:ws},je=window.localStorage,ks={getItem:t=>je.getItem(t),setItem:(t,n)=>je.setItem(t,n),removeItem:t=>je.removeItem(t),hasOwnProperty:t=>Object.hasOwn(je,t)},Ds={initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:se.spring},_s=()=>{const{functionData:t}=ae(),{data:n}=Kt(),[s,a]=x.useState(!1),[r,l]=x.useState(null),[u,d]=x.useState(null),[m,i]=x.useState(!0),c=x.useRef(void 0),h=Jt(),o=n?.name.split(" ")[0]||"John Doe",p=()=>t.name.includes("twilio-cage")?`{
2  "body": "Hey, your friend ${o} is using Evervault Functions",
3  "to": "<PHONE-NUMBER>"
4}
5
6`:`{
7  "name": "${o}"
8}
9
10
11`,v=t&&t.playgroundDefaults?JSON.stringify(t.playgroundDefaults,void 0,2):localStorage.getItem(`playground-${t.uuid}`)||p(),{mutateAsync:M}=Xt(t.uuid),R=async(S,C)=>{const ce=btoa(JSON.stringify(C)),j=await M({encodedPayload:ce}),k=new Headers;return k.append("authorization",`RunToken ${j.token}`),k.append("x-playground","true"),en.post(`functions/${S}/runs`,{prefixUrl:lt.apiUrls.public,headers:k,json:{payload:C}}).json()};x.useEffect(()=>{c.current=v},[]);const z=S=>h.encrypt(S),L=async()=>{try{const S=JSON.parse(c.current);if(typeof S!="object")throw new SyntaxError("The data must be a JSON object.");ks.setItem(`playground-${t.uuid}`,c.current),a(!0);const C=await z(S);l(JSON.stringify(C,void 0,2)),i(!0);const ce=await R(t.name,C);d(JSON.stringify(ce,void 0,2)),P.success("Function run completed"),a(!1)}catch(S){S instanceof SyntaxError&&P.warning("Data must be a JSON object"),a(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(ee,{title:"Playground",actions:e.jsx(f,{size:"sm",onClick:L,Icon:e.jsx(An,{}),loading:s||t?.latestDeployment?.status!=="deployed",disabled:t?.latestDeployment?.status!=="deployed",children:"Run Function"})}),e.jsxs("div",{className:"position-relative",children:[e.jsx(dt,{className:ie.label,children:"Input"}),e.jsx("div",{className:ie.codeWrapper,children:e.jsxs(ne,{initial:!1,children:[e.jsxs(N.div,{className:ie.code,...se.collapsible,children:[r&&!m&&e.jsx(f,{layoutId:"toggle-encrypted",size:"xs",type:"outlined",className:"position-absolute t-0 r-0 mt-1 mr-1",onClick:()=>i(!0),...Ds,children:"Show encrypted data"},"show-encrypted-data"),e.jsx(_t,{minHeight:"100px",language:"json",value:v,keyMap:[{key:"Cmd-Enter",run:L}],onChange:S=>{c.current=S}})]},"input"),m&&r&&e.jsx(Ke,{value:r,label:"Encrypted data",onClickLabel:()=>i(!1)},"encrypted-data"),u&&e.jsx(Ke,{value:u,label:"Output",onClickLabel:()=>d(null)},"output")]})})]}),e.jsx(ne,{initial:!1,children:!u&&e.jsx(N.p,{className:"mt-2 text-muted small",...se.collapsible,children:"Enter sample input above to encrypt it and send to your Function. The Function will decrypt it and output the result."})})]})},Ke=({value:t,label:n,onClickLabel:s,...a})=>e.jsxs(N.div,{className:ie.code,...se.collapsible,...a,children:[e.jsxs(dt,{className:he(ie.label,ie.labelClickable),initial:"initial",whileHover:"hover",onClick:s,children:[e.jsx(N.span,{variants:{initial:{width:0,marginRight:0,opacity:0}
11,hover:{width:"auto",marginRight:4,opacity:1}},transition:se.spring,children:"Hide"})," ",n]}),e.jsx(_t,{language:"json",minHeight:"100px",value:t,readOnly:!0})]}),Ss=`
12$ sh <(curl https://cli.evervault.com/v4/install -sL)
13$ ev --version
14`,As=`
15$ export EV_API_KEY=...
16$ export EV_APP_UUID=...
17$ ev function init
18$ cd hello-function
19$ ev function deploy
20`;function Fs(){return e.jsx("div",{className:"p-5",children:e.jsxs("div",{children:[e.jsx(A,{leading:"md",className:"mb-4",children:"You can use the Evervault CLI to initialize and deploy functions without having to authenticate with GitHub."}),e.jsx(A,{weight:500,className:"mb-2",children:"Install & Authenticate the CLI"}),e.jsx(ve,{className:"p-3 mb-5",children:e.jsx(Ye,{language:"bash",children:Ss})}),e.jsx(A,{weight:500,className:"mb-2",children:"Initialize & Deploy a Function"}),e.jsx(ve,{className:"p-3 mb-5",children:e.jsx(Ye,{language:"bash",children:As})}),e.jsxs(re,{external:!0,href:Se("/functions#deploying-a-function"),target:"_blank",children:["Learn More",e.jsx(Ue,{})]})]})})}var de={},Je;function Ns(){return Je||(Je=1,(function(t){var n=de&&de.__spreadArray||function(i,c,h){if(h||arguments.length===2)for(var o=0,p=c.length,g;o<p;o++)(g||!(o in c))&&(g||(g=Array.prototype.slice.call(c,0,o)),g[o]=c[o]);return i.concat(g||Array.prototype.slice.call(c))};Object.defineProperty(t,"__esModule",{value:!0}),t.adverbs=t.verbs=t.nouns=t.adjectives=void 0,t.humanId=l,t.poolSize=u,t.maxLength=d,t.minLength=m,t.adjectives=["afraid","all","beige","better","big","blue","bold","brave","breezy","bright","brown","bumpy","busy","calm","chatty","chilly","chubby","clean","clear","clever","cold","common","cool","cozy","crisp","cuddly","curly","curvy","cute","cyan","dark","deep","dirty","dry","dull","eager","early","easy","eight","eighty","eleven","empty","every","fair","famous","fancy","fast","few","fiery","fifty","fine","five","flat","floppy","fluffy","forty","four","frank","free","fresh","fruity","full","funky","funny","fuzzy","gentle","giant","gold","good","goofy","great","green","grumpy","happy","heavy","hip","honest","hot","huge","humble","hungry","icy","itchy","jolly","khaki","kind","large","late","lazy","legal","lemon","light","little","long","loose","loud","lovely","lucky","major","many","metal","mighty","modern","moody","neat","new","nice","nine","ninety","odd","old","olive","open","orange","perky","petite","pink","plain","plenty","polite","pretty","proud","public","puny","purple","quick","quiet","rare","ready","real","red","rich","ripe","salty","seven","shaggy","shaky","sharp","shiny","short","shy","silent","silly","silver","six","sixty","slick","slimy","slow","small","smart","smooth","social","soft","solid","some","sour","sparkly","spicy","spotty","stale","strict","strong","sunny","sweet","swift","tall","tame","tangy","tasty","ten","tender","thick","thin","thirty","three","tidy","tiny","tired","tough","tricky","true","twelve","twenty","two","upset","vast","violet","wacky","warm","wet","whole","wicked","wide","wild","wise","witty","yellow","young","yummy"],t.nouns=["apes","animals","areas","bars","banks","baths","breads","bushes","cloths","clowns","clubs","hoops","loops","memes","papers","parks","paths","showers","sides","signs","sites","streets","teeth","tires","webs","actors","ads","adults","aliens","ants","apples","baboons","badgers","bags","bananas","bats","beans","bears","beds","beers","bees","berries","bikes","birds","boats","bobcats","books","bottles","boxes","brooms","buckets","bugs","buses","buttons","camels","cases","cameras","candies","candles","carpets","carrots","carrots","cars","cats","chairs","chefs","chicken","clocks","clouds","coats","cobras","coins","corners","colts","comics","cooks","cougars","regions","results","cows","crabs","crabs","crews","cups","cities","cycles","dancers","days","deer","dingos","dodos","dogs","dolls","donkeys","donuts","doodles","doors","dots","dragons","drinks","dryers","ducks","ducks","eagles","ears","eels","eggs","ends","mammals","emus","experts","eyes","facts","falcons","fans","feet","files","flies","flowers","forks","foxes","friends","frogs","games","garlics","geckos","geese","ghosts","ghosts","gifts","glasses","goats","grapes","groups","guests","hairs","hands","hats","heads","hornet
20s","horses","hotels","hounds","houses","humans","icons","ideas","impalas","insects","islands","items","jars","jeans","jobs","jokes","keys","kids","kings","kiwis","knives","lamps","lands","laws","lemons","lies","lights","lines","lions","lizards","llamas","mails","mangos","maps","masks","meals","melons","mice","mirrors","moments","moles","monkeys","months","moons","moose","mugs","nails","needles","news","nights","numbers","olives","onions","oranges","otters","owls","pandas","pans","pants","papayas","parents","parts","parrots","paws","peaches","pears","peas","pens","pets","phones","pianos","pigs","pillows","places","planes","planets","plants","plums","poems","poets","points","pots","pugs","pumas","queens","rabbits","radios","rats","ravens","readers","rice","rings","rivers","rockets","rocks","rooms","roses","rules","schools","bats","seals","seas","sheep","shirts","shoes","shrimps","singers","sloths","snails","snakes","socks","spiders","spies","spoons","squids","stamps","stars","states","steaks","suits","suns","swans","symbols","tables","taxes","taxis","teams","terms","things","ties","tigers","times","tips","toes","towns","tools","toys","trains","trams","trees","turkeys","turtles","vans","views","walls","walls","wasps","waves","ways","weeks","windows","wings","wolves","wombats","words","worlds","worms","yaks","years","zebras","zoos"],t.verbs=["accept","act","add","admire","agree","allow","appear","argue","arrive","ask","attack","attend","bake","bathe","battle","beam","beg","begin","behave","bet","boil","bow","brake","brush","build","burn","buy","call","camp","care","carry","change","cheat","check","cheer","chew","clap","clean","cough","count","cover","crash","create","cross","cry","cut","dance","decide","deny","design","dig","divide","do","double","doubt","draw","dream","dress","drive","drop","drum","eat","end","enter","enjoy","exist","fail","fall","feel","fetch","film","find","fix","flash","float","flow","fly","fold","follow","fry","give","glow","go","grab","greet","grin","grow","guess","hammer","hang","happen","heal","hear","help","hide","hope","hug","hunt","invent","invite","itch","jam","jog","join","joke","judge","juggle","jump","kick","kiss","kneel","knock","know","laugh","lay","lead","learn","leave","lick","like","lie","listen","live","look","lose","love","make","march","marry","mate","matter","melt","mix","move","nail","notice","obey","occur","open","own","pay","peel","play","poke","post","press","prove","pull","pump","pick","punch","push","raise","read","refuse","relate","relax","remain","repair","repeat","reply","report","rescue","rest","retire","return","rhyme","ring","roll","rule","run","rush","say","scream","see","search","sell","send","serve","shake","share","shave","shine","show","shop","shout","sin","sink","sing","sip","sit","sleep","slide","smash","smell","smile","smoke","sneeze","sniff","sort","speak","spend","stand","start","stay","stick","stop","stare","study","strive","swim","switch","take","talk","tan","tap","taste","teach","tease","tell","thank","think","throw","tickle","tie","trade","train","travel","try","turn","type","unite","vanish","visit","wait","walk","warn","wash","watch","wave","wear","win","wink","wish","wonder","work","worry","write","yawn","yell"],t.adverbs=["bravely","brightly","busily","daily","freely","hungrily","joyously","knowlingly","lazily","oddly","mysteriously","noisily","politely","quickly","quietly","rapidly","safely","sleepily","slowly","truly","yearly"];function s(i){return i[Math.floor(Math.random()*i.length)]}function a(i){return i.reduce(function(c,h){return c.length>h.length?c:h})}function r(i){return i.reduce(function(c,h){return c.length<h.length?c:h})}function l(i){i===void 0&&(i={}),typeof i=="string"&&(i={separator:i}),typeof i=="boolean"&&(i={capitalize:i});var c=i.separator,h=c===void 0?"":c,o=i.capitalize,p=o===void 0?!0:o,g=i.adjectiveCount,v=g===void 0?1:g,M=i.addAdverb,R=M===void 0?!1:M,z=n(n(n([],n([],Array(v),!0).map(function(L){return s(t.adjectives)}),!0),[s(t.nouns),s(t.verbs)],!1),R?[s(t.adverbs)]:[],!0);return p&&(z=z.map(function(L){return L.charAt(0).toUpperCase()+L.substr(1)})),z.join(h)}function u(i){i===void 0&&(i={});var c=i.adjectiveCount,h=c===void 0?1:c,o=i.addAdverb,p=o===void 0?!1:o;return t.adjectives.length*h*t.nouns.length*t.verbs.length*(p?t.adverbs.length:1)}function d(i){i===void 0&&(i={});var c=i.adjectiveCount,h=c===void 0?1:c,o=i.addAdverb,p=o===void 0?!1:o,g=i.separator,v=g===void 0?"":g;return a(t.adjectives).length*h+h*v.length+a(t.nouns).length+v.length+a(t.verbs).length+(p?a(t.adverbs).length+v.length:0)}function m(i){i===void 0&&(i={});var c=i.adjectiveCount,h=c===void 0?1:c,o=i.addAdverb,p=o===void 0?!1:o,g=i.separator,v=g===void 0?"":g;return r(t.adjectives).length*h+h*v.length+r(t.nouns).length+v.length+r(t.verbs).length+(p?r(t.adverbs).length+v.length:0)}t.default=l})(de)),de}var Es=Ns();const Cs=tn(Es);function We(){const{teamUuid:t,appUuid:n}=$();if(!t||!n)throw new Error("Missing teamUuid or appUuid in url");return ut({retry:!1,refetchOnMount:!1,useErrorBoundary:!1,refetchOnWindowFocus:!1,queryKey:["github-installations"],queryFn:async()=>{let s=await Xe(t,n);if(s?.installations.length===0){const a=await Is(t,n);if(a.tokenPresent)s=await Xe(t,n);else return{authenticated:!1,authenticationUrl:a.url,installations:[]}}return{authenticated:!0,authenticationUrl:"",installations:s.installations}}})}async function Xe(t,n){const s=`teams/${t}/apps/${n}/github/installs`;return await oe.get(s).json()}async function Is(t,n){const s=`teams/${t}/apps/${n}/github/login`;return await oe.get(s).json()}function Ms(){const{data:t}=We(),{teamUuid:n,appUuid:s}=$();if(!n||!s)throw new Error("Missing teamUuid or appUuid in url");return ut({queryKey:["github-repositories"],queryFn:async()=>{const a=(t?.installations||[]).map(async l=>(await Rs(n,s,l.id)).repos.map(d=>({...d,installationId:l.id})));return(await Promise.all(a)).flat()}})}async function Rs(t,n,s){const a=`teams/${t}/apps/${n}/github/repos`;return await oe.get(a,{searchParams:{githubInstallId:s}}).json()}function Mt(){const t=it(),{teamUuid:n,appUuid:s}=$();if(!n||!s)throw new Error("Missing teamUuid or appUuid in url");return Te({mutationFn:async a=>oe.post(`teams/${n}/apps/${s}/functions/github/install`,{json:a,timeout:3e4}).json(),onSettled:async()=>{await t.invalidateQueries({queryKey:rt.functions(n,s)})},onError:async(a,r)=>{const l=await a.response.json();switch(l?.code){case"unique-validation-error":P.warning(`Function "${r.repoName}" already exists`);break;
20case"resource-exhausted":P.warning(l.message||"Resource exhausted, try again later");break;default:P.error(l.message||"Failed to deploy function");break}}})}const Ts="_search_19jgg_26",Ls="_refresh_19jgg_33",Ps="_repos_19jgg_61",Os="_repo_19jgg_61",Vs="_repoName_19jgg_94",Us="_repoTimestamp_19jgg_102",$s="_services_19jgg_109",zs="_service_19jgg_109",Hs="_connectionIcon_19jgg_132",Ws="_githubAuth_19jgg_151",Bs="_button_19jgg_158",Gs="_template_19jgg_162",Ys="_githubIcon_19jgg_219",qs="_organizationSelect_19jgg_223",Zs="_repository_19jgg_227",Qs="_details_19jgg_236",D={search:Ts,refresh:Ls,repos:Ps,repo:Os,repoName:Vs,repoTimestamp:Us,services:$s,service:zs,connectionIcon:Hs,githubAuth:Ws,button:Bs,template:Gs,githubIcon:Ys,organizationSelect:qs,repository:Zs,details:Qs};function Rt(t){const n=Cs({separator:"-",capitalize:!1});return`${t}-${n}`.replace("template-","")}const Ks=X({name:H().min(2,"Please provide a name for your repository."),installation:H().min(1,"Please select a GitHub Organization."),template:H().min(1,"Please select a template.")}),Me=[{value:"template-node-hello-function",icon:e.jsx(En,{}),title:"Node.js Starter",description:"A simple Hello World function written in Node.js."},{value:"template-python-hello-function",icon:e.jsx(Cn,{}),title:"Python Starter",description:"A simple Hello World function written in Python."}];function Js(){const t=ge(),n=Q(),{teamUuid:s,appUuid:a}=$(),{data:r}=We(),{mutateAsync:l,isLoading:u}=Mt(),d=G({resolver:K(Ks),defaultValues:{template:Me[0].value,installation:r?.installations[0].id.toString()||"",name:Rt(Me[0].value)}}),m=mt({name:"installation",control:d.control}),i=r?.installations.find(o=>o.id.toString()===m.field.value);if(!i)throw new Error("Installation not found");const c=d.handleSubmit(async o=>{const{func:p}=await l({repoName:o.name,installationId:m.field.value,repoOwner:i.account.login,githubAccountType:i.account.type,templateRepo:o.template,privateRepo:!0});p&&(ht.success("Function created"),t(`/${s}/${a}/functions/${p.name}/general`),pt.track("created_function",{id:p.uuid,name:p.name,app:p.appUuid,team:p.teamUuid}),n?.close())}),h=o=>{o.preventDefault(),window.open(St(),"_blank")};return e.jsx(nn,{...d,children:e.jsxs("form",{onSubmit:c,children:[e.jsx(U,{gap:"20px",className:"mb-5",children:Me.map(o=>e.jsx(Xs,{value:o.value,icon:o.icon,title:o.title,children:o.description},o.value))}),e.jsxs(J,{label:"Repository",className:"mb-6",children:[e.jsxs(sn,{children:[e.jsx(qe,{className:D.organizationSelect,prefix:e.jsx(we,{className:D.githubIcon}),value:m.field.value,onChange:m.field.onChange,children:(r?.installations||[]).map(o=>e.jsx(qe.Option,{value:o.id.toString(),children:o.account.login},o.id))}),e.jsx(le,{...d.register("name"),placeholder:"Repository Name",error:!!d.formState.errors.name})]}),e.jsx(A,{color:"var(--grey-60)",size:"sm",className:"mt-2",children:"This will create a new private repository on GitHub."})]}),e.jsx(f,{style:{width:"100%"},size:"lg",variant:"primary",className:"mb-4",loading:u,children:"Create Repository & Deploy Function"}),e.jsxs(A,{size:"sm",className:"text-center",color:"var(--grey-60)",children:["Can't see your GitHub Organization here? ",e.jsx(re,{href:"#",onClick:h,children:"Configure the Evervault app on GitHub"})]})]})})}function Xs({icon:t,title:n,children:s,value:a}){const r=an(),{field:l}=mt({name:"template"}),u=()=>{l.onChange(a),r.formState.dirtyFields.name||r.setValue("name",Rt(a),{shouldDirty:!1})};return e.jsxs("div",{onClick:u,className:D.template,"aria-selected":l.value===a,children:[e.jsxs("h6",{children:[t," ",n]}),e.jsx("p",{children:s})]})}const ea=t=>e.jsx("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.718 2.625a1.379 1.379 0 0 0-.713 1.093A1.764 1.764 0 0 1 1 3.613v4.445c0-.03.002-.058.005-.087A1.755 1.755 0 0 0 2.209 9.51l.826.27-1.317.72a1.379 1.379 0 0 0-.713 1.093A1.768 1.768 0 0 1 1 11.487v4.445c0-.03.002-.058.005-.087a1.755 1.755 0 0 0 1.204 1.538l6.646 2.177a8.866 8.866 0 0 0 7.007-.644l2.823-1.54c.408-.223.675-.635.714-1.094.002.035.004.07.004.105v-4.445c0 .03-.002.058-.004.087a1.755 1.755 0 0 0-1.205-1.538l-.826-.27 1.317-.72c.408-.222.675-.634.714-1.093.002.035.004.07.004.105V4.068c0 .03-.002.058-.004.087a1.755 1.755 0 0 0-1.205-1.538L11.55.44a8.866 8.866 0 0 0-7.008.644l-2.823 1.54Zm2.034 7.39-1.77.966a.83.83 0 0 0-.433.704v.126c.01.67.467 1.258 1.137 1.467l.373.116 2.834-1.547a5.158 5.158 0 0 1 1.705-.573l-3.846-1.26Zm8.194 2.105a8.862 8.862 0 0 0 3.916-1.078l.844-.46 1.317.431c.489.16.822.612.83 1.125v.08c-.01.44-.267.842-.674 1.053l-1.053.545-5.18-1.696Zm-3.01-4.773-5.146-1.6 2.366-1.291A4.61 4.61 0 0 1 9.8 4.12l6.643 2.175-.919.476a8.736 8.736 0 0 1-6.589.575ZM9.97 3.599l7.155 2.343 1.053-.545c.407-.211.665-.613.675-1.053v-.08a1.206 1.206 0 0 0-.83-1.125L11.376.962a8.317 8.317 0 0 0-6.573.604L1.981 3.107a.83.83 0 0 0-.432.704v.126c.01.67.467 1.258 1.137 1.467l.373.116 2.834-1.547A5.16 5.16 0 0 1 9.97 3.6ZM8.935 15.22l-5.145-1.6 2.366-1.291a4.61 4.61 0 0 1 3.644-.335l6.643 2.175-.919.476a8.736 8.736 0 0 1-6.589.575Z",fill:"currentColor"})});function et({children:t,message:n}){const{data:s,isInitialLoading:a,refetch:r}=We();if(a)return e.jsx(ct.Loader,{});const l=async()=>{r()};return s&&!s.authenticated?e.jsx(ta,{url:s.authenticationUrl,onComplete:l,message:n}):t}function ta({url:t,onComplete:n,message:s}){const{teamUuid:a,appUuid:r}=$(),l=In({onComplete:n});if(!a||!r)throw new Error("Missing teamUuid or appUuid in url");const u=()=>{l.start(t,{teamUuid:a,appUuid:r})};return e.jsxs("div",{className:D.githubAuth,children:[e.jsxs("div",{className:D.services,children:[e.jsx("div",{className:D.service,children:e.jsx(ea,{})}),e.jsx("div",{className:D.connectionIcon,children:e.jsx(rn,{})}),e.jsx("div",{className:D.service,children:e.jsx(we,{})})]}),e.jsxs("div",{className:D.copy,children:[e.jsx(A.Heading,{size:"xs",className:"mb-1",children:"Connect to GitHub"}),e.jsx(A,{size:"sm",leading:"md",className:"mb-5",children:s}),e.jsxs(f,{onClick:u,disabled:l.pending,className:D.button,children:[e.jsx(we,{}),l.pending?"Connecting...":"Authenticate with GitHub"]})]})]})}function na({onSelect:t}){const[n,s]=x.useState(""),{data:a,isLoading:r,refetch:l,isRefetching:u}=Ms(),d=()=>{l()},m=r||u,i=x.useMemo(()=>
20{if(!a)return[];const c=new Mn(a??[],{keys:["name","full_name"],threshold:.2,minMatchCharLength:2});return(n?c.search(n).map(({item:o})=>o):a).sort((o,p)=>{const g=new Date(o.pushed_at||o.updated_at).getTime();return new Date(p.pushed_at||p.updated_at).getTime()-g})},[a,n]);return e.jsxs("div",{children:[e.jsxs("div",{className:D.search,children:[e.jsxs(Ne,{size:"sm",children:[e.jsx(Ne.Input,{autoFocus:!0,value:n,onChange:c=>s(c.target.value),type:"text",placeholder:"Search..."}),e.jsx(Ne.Addon,{children:e.jsx(on,{})})]}),e.jsx("button",{className:D.refresh,onClick:d,disabled:m,children:e.jsx(Gn,{})})]}),e.jsx("div",{style:{maxHeight:300,overflow:"auto"},className:D.repos,children:e.jsxs(ln,{children:[!m&&i.map(c=>e.jsx("div",{className:D.repo,children:e.jsxs(U,{justify:"between",children:[e.jsxs("div",{children:[e.jsx("div",{className:D.repoName,children:c.full_name}),e.jsxs("div",{className:D.repoTimestamp,children:["Updated"," ",Kn(new Date,c.pushed_at||c.updated_at)," ","ago"]})]}),e.jsxs(f,{size:"xs",onClick:()=>t(c),children:["Import",e.jsx(cn,{})]})]})},c.id)),!m&&i.length===0&&e.jsx(A,{className:"text-center py-5",size:"sm",children:"No repositories found."}),m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:D.repo,children:e.jsx(Ee,{width:220,height:12})}),e.jsx("div",{className:D.repo,children:e.jsx(Ee,{width:270,height:12})}),e.jsx("div",{className:D.repo,children:e.jsx(Ee,{width:170,height:12})})]})]})})]})}function sa(){const[t,n]=x.useState(null),s=a=>{a.preventDefault(),window.open(St(),"_blank")};return e.jsx(ne,{mode:"popLayout",initial:!1,children:t?e.jsx(N.div,{initial:{opacity:0,x:30},animate:{opacity:1,x:0},exit:{opacity:0,x:30},children:e.jsx(ia,{repo:t,onBack:()=>n(null)})},"import"):e.jsxs(N.div,{initial:{opacity:0,x:-30},animate:{opacity:1,x:0},exit:{opacity:0,x:-30},children:[e.jsx(na,{onSelect:n}),e.jsx("div",{className:"p-5 text-center",children:e.jsxs(A,{size:"sm",color:"var(--grey-60)",children:["Can't see your repo here? ",e.jsx(re,{href:"#",onClick:s,target:"_blank",children:"Configure the Evervault app on GitHub"})]})})]},"select-repo")})}const aa=X({directory:H().regex(/^(\.\/)?([A-Za-z0-9-_+]+\/?)*$/,{message:"The subdirectory must be a valid file path."}).optional().or(ot(""))});function ia({repo:t,onBack:n}){const s=ge(),a=Q(),r=Mt(),l=G({resolver:K(aa),defaultValues:{directory:""}}),u=l.handleSubmit(async d=>{const m=d.directory?.replace(/^\.\//,"")||void 0,{func:i}=await r.mutateAsync({installationId:t.installationId,githubAccountType:t.owner.type,repoName:t.name,repoOwner:t.owner.login,subdirectory:m});i&&(ht.success("Function created"),s(`${i.name}/general`),pt.track("created_function",{id:i.uuid,name:i.name,app:i.appUuid,team:i.teamUuid}),a.close())});return e.jsxs("form",{onSubmit:u,className:"p-5",children:[e.jsxs(ve,{className:D.repository,children:[e.jsx(we,{}),e.jsxs("div",{className:D.details,children:[e.jsx("h6",{children:t.full_name}),e.jsx(re,{target:"_blank",href:t.html_url,children:t.html_url})]}),e.jsx(f,{type:"button",size:"xs",onClick:n,children:"Change"})]}),e.jsx(J,{label:"Subdirectory",className:"mb-6",children:e.jsx(le,{placeholder:"functions/request-signer",...l.register("directory")})}),e.jsx(f,{style:{width:"100%"},size:"lg",variant:"primary",className:"mb-4",loading:r.isLoading,children:"Deploy Function"}),e.jsx(A,{className:"text-center",size:"sm",color:"var(--grey-60)",children:"Any future commits to this repository will automatically deploy the Function."})]})}function ra(t){return e.jsxs(b,{state:t.state,closeButton:!0,children:[e.jsx("div",{className:"pt-5 px-5 pb-2",children:e.jsx(A.Heading,{children:"Deploy Function"})}),e.jsxs(fe,{className:"px-5",children:[e.jsx(fe.Tab,{label:"Import Repository",children:e.jsx(et,{message:"Connect your GitHub account to Evervault to import a Function and deploy it any time you push a change to GitHub.",children:e.jsx(sa,{})})}),e.jsx(fe.Tab,{label:"Templates",children:e.jsx(et,{message:"Connect your GitHub account to Evervault to import and deploy one of our Function templates.",children:e.jsx("div",{className:"p-5",children:e.jsx(Js,{})})})}),e.jsx(fe.Tab,{label:"CLI",children:e.jsx(Fs,{})})]})]})}const oa=({func:t})=>{const{data:n}=Fn(t.uuid);return e.jsx(Nn,{name:t.name,data:n,text:Z(t.createdAt).fromNow(),to:`${t.name}/general`})},la="_cards_g0jy6_1",ca={cards:la},da="_container_1sz5o_1",ua={container:da};function ma({instances:t=2}){return new Array(t).fill("").map((s,a)=>e.jsx("div",{"data-testid":"skeletonCard",className:ua.container},`skeleton-${a}`))}const ha=t=>wt(bt(kt("createdAt")),t);function pa(){const t=B(),n=B(),{teamUuid:s}=$(),{data:a}=dn(s,{suspense:!0,select:un}),{data:r,isInitialLoading:l}=gt({suspense:!0,select:ha}),u=a!=="ready",d=n.open;return e.jsxs(e.Fragment,{children:[e.jsx(ra,{state:t}),e.jsx(b,{state:n,children:e.jsx(b.Body,{children:e.jsx(_n,{embedId:"OzBjSwiasNw"})})}),e.jsx(ee,{title:"Functions",actions:e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{"data-testid":"create-function",size:"sm",variant:"primary",onClick:t.open,disabled:u}),children:"Create Function"})}),r?.length===0&&e.jsxs(Ce,{asset:e.jsx(Tn,{}),title:"Process your Encrypted Data",description:"Secure serverless functions that allow you to run logic and processing on fully encrypted data, without exposing your infrastru
20cture to sensitive information.",children:[e.jsx(Ce.PrimaryCard,{title:"Follow a Getting Started tutorial in the Evervault Docs.",href:Se("/functions"),cta:"Get Started",asset:Ln}),e.jsx(Ce.SecondaryCard,{grow:!0,title:"Watch a Tutorial",onClick:d,icon:e.jsx(Sn,{width:17})})]}),e.jsx("div",{className:ca.cards,children:l?e.jsx(ma,{instances:2}):r?.map(m=>e.jsx(oa,{func:m},m.uuid))})]})}const tt={initialization:["initiated","creatingRepo","uploadingTemplate","importingRepo","uploading"],build:["startingBuild","packaging","queuedForBuilding","building"],provisioning:["provisioning"]},ga=t=>Object.keys(tt).find(n=>tt[n].includes(t));function Re({inProgress:t,isComplete:n,title:s,status:a,...r}){return e.jsxs(N.div,{className:he(w.deploymentStep,{[w.deploymentStepActive]:t,[w.deploymentStepComplete]:n}),...r,children:[e.jsx(N.div,{layout:"position",children:t?e.jsx(yt,{className:w.deploymentStepSpinner}):e.jsx("div",{className:w.deploymentStepCheck,children:n&&e.jsx(hn,{strokeWidth:3,size:12})})}),e.jsxs("div",{children:[e.jsx(N.h5,{layout:"position",className:w.deploymentStepTitle,children:s}),t&&e.jsx(N.div,{initial:{opacity:0}
20,animate:{opacity:1},className:w.deploymentStepStatus,children:a})]})]})}function ya({deployment:t}){const{status:n}=t,s=n==="deployed",a=ga(n),r=a==="initialization",l=a==="build",u=a==="provisioning";return e.jsx(ne,{children:Nt(n)&&e.jsx(N.div,{initial:{height:"auto"},animate:{height:"auto"},exit:{height:0},className:w.deployment,children:e.jsxs(mn,{children:[e.jsx(Re,{layoutId:"init",inProgress:r,isComplete:!r,title:l||u?"Initiated Function":"Initializing Function...",status:me(t)}),e.jsx(Re,{layoutId:"build",inProgress:l,isComplete:u,title:u?"Built Function":"Building Function...",status:me(t)}),e.jsx(Re,{layoutId:"prov",isComplete:s,inProgress:u,title:"Provisioning Function infrastructure...",status:me(t)})]})},"deployment")})}function fa({deployment:t}){const{isLoading:n,data:s}=pn(t),a=x.useCallback(()=>{s&&window.open(s.signedUrl,"_blank")},[s]);return e.jsx(xe.Item,{icon:e.jsx(zn,{}),loading:n,onSelect:a,children:"Download"})}function ja({deployment:t}){return e.jsxs(xe,{children:[e.jsx(xe.Trigger,{asChild:!0,children:e.jsx(f,{size:"xs","aria-label":"Version options",children:e.jsx(Pn,{"aria-hidden":!0})})}),e.jsx(xe.List,{children:e.jsx(fa,{deployment:t})})]})}function xa({deployment:t,handleClickGithub:n}){return e.jsxs("li",{"data-testid":`version-${t.functionVersion}`,className:w.versionRow,children:[e.jsxs("div",{className:w.versionDetails,children:[e.jsxs("div",{className:w.versionNameAndDeployment,children:[e.jsxs("h6",{className:w.versionName,children:["Version ",t.functionVersion]}),e.jsxs("p",{className:w.versionInfo,children:[e.jsx("span",{className:he(Qe.truncate,w.deployedBy),children:t.deployedBy.name}),t.type&&e.jsxs("span",{className:he(w.deploymentType),children:[" via ",t.type==="github"?e.jsxs("span",{className:Qe.link,title:"View commit on GitHub",onClick:()=>n(t),children:["GitHub",t.commitHash&&` (${t.commitHash?.substring(0,7)})`]}):t.type.toUpperCase()]})]})]}),e.jsxs(U,{align:"end",direction:"column",children:[e.jsx(Ct,{deployment:t}),e.jsx(V,{content:Z(t.deployedAt||t.createdAt).format("MMMM DD, YYYY, hh:mm a"),children:e.jsx("div",{className:w.versionTimestamp,children:Z().to(t.deployedAt||t.createdAt)})})]}),e.jsx(ja,{deployment:t})]}),He(t.status)&&e.jsxs("div",{className:w.deploymentError,children:[e.jsx(gn,{size:16,color:"var(--grey-60)",style:{fill:"none"}}),t.failureReason]}),e.jsx(ya,{deployment:t})]})}const ba=()=>{const{functionData:t}=ae(),{data:n,isInitialLoading:s,isFetching:a,refetch:r,error:l}=yn(t.uuid),u=wt(bt(kt("id")),n??[]),d=async(i=!1)=>{const c=r();i&&E.promise(c,{loading:"Loading new versions",success:"Versions up-to-date",error:"Failed to fetch versions"}),await c},m=i=>{const c=`${t.githubRepo?.url}/commit/${i.commitHash}`;window.open(c,"_blank")};return e.jsxs(e.Fragment,{children:[e.jsx(ee,{title:"Versions",actions:e.jsx(V,{content:"Refresh",children:e.jsx(f,{onClick:async()=>await d(!0),"data-testid":"refresh-versions",whileHover:{rotate:360},whileTap:{scale:.9},loading:a,transition:se.spring,className:"my-1",children:e.jsx(On,{})})})}),s&&e.jsx(yt.Page,{}),l&&e.jsx(Ze,{className:"p-8",children:e.jsx(A,{className:"text-center",children:"Failed to fetch function deployments"})}),!s&&!l&&e.jsx(Ze,{className:w.overflow,children:e.jsxs(ne,{initial:!1,children:[u.length===0&&e.jsxs(te,{children:[e.jsx(te.Icon,{children:e.jsx(Un,{})}),e.jsx(te.Title,{children:"No deployments"}),e.jsx(te.Text,{children:"This function has not been deployed yet"})]}),u.map((i,c)=>e.jsx(xa,{deployment:i,handleClickGithub:m},c))]})})]})};function va(){return e.jsxs(te,{children:[e.jsx(te.Icon,{children:e.jsx(Wn,{})}),e.jsx(te.Title,{children:"Inbound Whitelist"}),e.jsx(A,{size:"sm",leading:"md",children:"By default, your Function has no restrictions on what IP address an invocation can come from, but you can restrict it to specific IP addresses."}),e.jsxs(re,{external:!0,href:Se("/functions#networking"),children:["Learn More",e.jsx(Ue,{})]})]})}function Tt(t){if(t==null)throw new TypeError("Expected a string but received a ".concat(t));if(t.constructor.name!=="String")throw new TypeError("Expected a string but received a ".concat(t.constructor.name))}function Oe(t){"@babel/helpers - typeof";return Oe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Oe(t)}var nt="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",q="(".concat(nt,"[.]){3}").concat(nt),wa=new RegExp("^".concat(q,"$")),_="(?:[0-9a-fA-F]{1,4})",ka=new RegExp("^("+"(?:".concat(_,":){7}
20(?:").concat(_,"|:)|")+"(?:".concat(_,":){6}(?:").concat(q,"|:").concat(_,"|:)|")+"(?:".concat(_,":){5}(?::").concat(q,"|(:").concat(_,"){1,2}|:)|")+"(?:".concat(_,":){4}(?:(:").concat(_,"){0,1}:").concat(q,"|(:").concat(_,"){1,3}|:)|")+"(?:".concat(_,":){3}(?:(:").concat(_,"){0,2}:").concat(q,"|(:").concat(_,"){1,4}|:)|")+"(?:".concat(_,":){2}(?:(:").concat(_,"){0,3}:").concat(q,"|(:").concat(_,"){1,5}|:)|")+"(?:".concat(_,":){1}(?:(:").concat(_,"){0,4}:").concat(q,"|(:").concat(_,"){1,6}|:)|")+"(?::((?::".concat(_,"){0,5}:").concat(q,"|(?::").concat(_,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");function pe(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Tt(t);var s=(Oe(n)==="object"?n.version:arguments[1])||"";return s?s.toString()==="4"?wa.test(t):s.toString()==="6"?ka.test(t):!1:pe(t,{version:4})||pe(t,{version:6})}var Da=/^\d{1,3}$/,st=32,at=128;function _a(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";Tt(t);var s=t.split("/");if(s.length!==2||!Da.test(s[1])||s[1].length>1&&s[1].startsWith("0"))return!1;var a=pe(s[0],n);if(!a)return!1;var r=null;switch(String(n)){case"4":r=st;break;case"6":r=at;break;default:r=pe(s[0],"6")?at:st}return s[1]<=r&&s[1]>=0}const Sa=X({addresses:xt(H()).min(1,"Please add at least one IP address").refine(t=>t.every(n=>pe(n,"4")||_a(n,"4")),"Please ensure the IP addresses you have added are valid")});function Aa({functionUuid:t}){const n=Q(),{mutateAsync:s}=fn(t),{control:a,handleSubmit:r,formState:{isSubmitting:l,errors:u,isValid:d}}=G({mode:"onTouched",defaultValues:{addresses:[]},resolver:K(Sa)}),m=async({addresses:i})=>{try{await s({addresses:i}),E.success("Inbound whitelist updated"),n.close()}catch(c){E.error(c.message||"Failed to update inbound whitelist")}};return e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Once you add an IP address, all invocations from IPs not on the list will be blocked."}),e.jsxs("form",{onSubmit:r(i=>m(i)),children:[e.jsx(ft,{name:"addresses",type:"select",control:a,render:({field:{ref:i,name:c,onChange:h,value:o,disabled:p,onBlur:g}})=>e.jsx(J,{label:"Addresses",helperText:"Add IP addresses you want to allow invocations from.",error:u.addresses?.message,children:e.jsx(jt,{ref:i,name:c,value:o,onValueChange:h,delimiter:/,\s*/,placeholder:"e.g. 192.168.0.1, 192.168.0.0/16",disabled:p,onBlur:g})})}),e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{className:"mt-3",loading:l,disabled:!d,variant:"primary"}),children:"Add addresses"})]})]})}const Fa=t=>X({address:ze(t,{nonempty_error:"Enter the IP address to remove it",invalid_value_error:`Must match ${t} exactly`})});function Na({row:t,functionUuid:n}){const s=Q(),{mutateAsync:a}=jn(n),{register:r,handleSubmit:l,formState:{isSubmitting:u,errors:d}}=G({mode:"onTouched",defaultValues:{address:""},resolver:K(Fa(t.address))}),m=async()=>{try{await a(t.key),E("IP address removed"),s.close()}catch(i){E.error(i.message||"Failed to remove IP address")}};return e.jsxs("form",{onSubmit:l(i=>m()),children:[e.jsxs(W,{className:"mb-4",variant:"danger",children:[e.jsx(W.Title,{children:"This action cannot be undone"}),"This will remove the IP address from the allowed list instantly. All Function invocations will be rejected."]}),e.jsx(J,{className:"mb-4",label:e.jsxs(e.Fragment,{children:["Please type ",e.jsx("b",{children:t.address})," to confirm"]}),error:d?.name?.message,children:e.jsx(le,{...r("address"),placeholder:t.address,"data-1p-ignore":!0})}),e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{variant:"danger",loading:u,disabled:!Ae(d)}),children:"Remove IP address"})]})}function Ea(){const{functionData:t}=ae(),n=B(),s=B(),[a,r]=x.useState(null),{enabled:l}=_e("superuser"),u=!t.disabled||l,d=c=>{r(c),s.open()},m=[{title:"IP Address",dataIndex:"address",key:"ip-address"},{title:"Updated At",dataIndex:"updatedAt",key:"updatedAt"},{title:"",dataIndex:"delete",width:50,align:"right",render:(c,h)=>e.jsx(V,{content:"Delete",side:"top",children:e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{variant:"danger",size:"sm",onClick:()=>d(h)}),children:e.jsx($e,{"aria-hidden":!0})})})}],i=t?.inboundWhitelist?.map(({id:c,updatedAt:h,address:o})=>({key:c,address:o,updatedAt:Z(h).format("MMM DD, YYYY, h:mm a")}));return e.jsxs(e.Fragment,{children:[e.jsxs(b,{state:n,children:[e.jsx(b.Header,{title:"Add IP addresses"}),e.jsx(b.Body,{children:e.jsx(Aa,{functionUuid:t?.uuid})})]}),e.jsxs(b,{state:s,children:[e.jsx(b.Header,{title:"Remove IP address"}),e.jsx(b.Body,{children:a&&e.jsx(Na,{row:a,functionUuid:t?.uuid})})]}),e.jsx(ee,{title:"Inbound Whitelist",actions:u&&e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{"data-testid":"create-button-with-variables",variant:"primary",size:"sm",onClick:n.open}),children:"Add IP addresses"})}),e.jsx(Dt,{className:"mb-6",columns:m,data:i,"data-testid":"whitelist",emptyText:e.jsx(va,{})})]})}const Ca=t=>x.createElement("svg",{width:240,height:70,viewBox:"0 0 240 70",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},x.createElement("path",{d:"M134.482 26.3333H118.482C116.273 26.3333 114.482 28.1242 114.482 30.3333V33C114.482 35.2091 116.273 37 118.482 37H134.482C136.691 37 138.482 35.2091 138.482 33V30.3333C138.482 28.1242 136.691 26.3333 134.482 26.3333Z",fill:"#E4E4EF",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M134.482 37H118.482C116.273 37 114.482 38.7909 114.482 41V43.6667C114.482 45.8758 116.273 47.6667 118.482 47.6667H134.482C136.691 47.6667 138.482 45.8758 138.482 43.6667V41C138.482 38.7909 136.691 37 134.482 37Z",fill:"#E4E4EF",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M119.815 31.6667V31.68",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M119.815 42.3333V42.3467",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{d:"M54.4819 9.1C53.9849 9.1 53.5819 9.50294 53.5819 10C53.5819 10.4971 53.9849 10.9 54.4819 10.9V9.1ZM113.482 33L105.02 26.9664L104.026 37.311L113.482 33ZM54.4819 10.9C65.9967 10.9 73.5425 15.3276 80.7782 20.3478C87.9959 25.3555 95.012 31.0564 105.242 33.1073L105.596 31.3424C95.8194 29.3824 89.1579 23.9709 81.8043 18.8689C74.4686 13.7793 66.5494 9.1 54.4819 9.1V10.9Z",fill:"#E4E4F0"}),x.createElement("path",{d:"M30.4819 68C62.3986 68 70.5653 45 102.482 45",fill:"none",stroke:"#E4E4F0",strokeWidth:1.8,strokeLinecap:"round"}),x.createElement("path",{d:"M107.482 42L101.482 48M101.482 42L107.482 48L101.482 42Z",stroke:"#E4E4EF",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}));function Ia(){return e.jsxs(U,{align:"center",direction:"column",justify:"center",children:[e.jsx(Ca,{className:"mt-3 mb-5"}),e.jsxs("p",{className:"w-70 text-center",children:["Your Function is currently blocking all outbound network requests, but you can",e.jsxs("b",{className:"color-secondary-60",children:[" ","whitelist specific domains or ",e.jsx("code",{children:"*"})," for all domains"]}),"."]})]})}const Ma=t=>/^(^:http(s)?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]+$/.test(t),Ra=t=>t==="*",Ta=X({domains:xt(H()).min(1,"Please add at least one domain").refine(t=>t.every(n=>Ra(n)||Ma(n)),{message:"Please ensure the domains you have added are valid"})});function La({functionUuid:t}){const n=Q(),{mutateAsync:s}=xn(t),{control:a,handleSubmit:r,formState:{isSubmitting:l,errors:u,isValid:d}}=G({mode:"onTouched",defaultValues:{domains:[]},resolver:K(Ta)}),m=async({domains:i})=>{try{await s({domains:i}),E.success("Outbound whitelist updated"),n.close()}catch(c){E.error(c.message||"Failed to update outbound whitelist")}};return e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Once you add a domain, all outbound requests from domains not on the list will be blocked."}),e.jsxs("form",{onSubmit:r(i=>m(i)),children:[e.jsx(ft,{name:"domains",type:"select",control:a,render:({field:{ref:i,name:c,onChange:h,value:o,disabled:p,onBlur:g}})=>e.jsx(J,{label:"Domains",error:u.domains?.message,children:e.jsx(jt,{ref:i,name:c,value:o,onValueChange:h,delimiter:
20/,\s*/,placeholder:"e.g. api.stripe.com",disabled:p,onBlur:g})})}),e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{className:"mt-3",loading:l,disabled:!d,variant:"primary"}),children:"Add domains"})]})]})}const Pa=t=>X({domainName:ze(t,{nonempty_error:"Enter your domain name to delete it",invalid_value_error:`Must match ${t} exactly`})});function Oa({row:t,functionUuid:n}){const s=Q(),{mutateAsync:a}=bn(n),{register:r,handleSubmit:l,formState:{isSubmitting:u,errors:d,isValid:m}}=G({mode:"onTouched",defaultValues:{domainName:""},resolver:K(Pa(t.domainName))}),i=async()=>{try{await a(t.key),E("Domain removed."),s.close()}catch(c){E.error(c.message||"Failed to remove domain")}};return e.jsxs("form",{onSubmit:l(c=>i()),children:[e.jsxs(W,{className:"mb-4",variant:"danger",children:[e.jsx(W.Title,{children:"This action cannot be undone"}),"This will remove the domain from the allowed list instantly. All requests to this domain will be rejected."]}),e.jsx(J,{className:"mb-4",label:e.jsxs(e.Fragment,{children:["Please type ",e.jsx("b",{children:t.domainName})," to confirm"]}),error:d?.name?.message,children:e.jsx(le,{...r("domainName"),placeholder:t.domainName,"data-1p-ignore":!0})}),e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{variant:"danger",loading:u,disabled:!Ae(d)||!m}),children:"Remove domain"})]})}function Va(){const{functionData:t}=ae(),n=B(),s=B(),[a,r]=x.useState(null),{enabled:l}=_e("superuser"),u=!t.disabled||l,d=c=>{r(c),s.open()},m=[{title:"Domain",dataIndex:"domainName",key:"domainName"},{title:"Updated At",dataIndex:"updatedAt",key:"updatedAt"},{title:"",dataIndex:"delete",width:50,align:"right",render:(c,h)=>e.jsx(V,{content:"Delete",children:e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{variant:"danger",size:"sm",onClick:()=>d(h)}),children:e.jsx($e,{"aria-hidden":!0})})})}],i=t?.outboundWhitelist?.map(({id:c,updatedAt:h,domainName:o})=>({key:c,domainName:o,updatedAt:Z(h).format("MMM DD, YYYY, h:mm a")}));return e.jsxs(e.Fragment,{children:[e.jsxs(b,{state:n,children:[e.jsx(b.Header,{title:"Add domains"}),e.jsx(b.Body,{children:e.jsx(La,{functionUuid:t?.uuid})})]}),e.jsxs(b,{state:s,children:[e.jsx(b.Header,{title:"Remove domain"}),e.jsx(b.Body,{children:a&&e.jsx(Oa,{row:a,functionUuid:t?.uuid})})]}),e.jsx(ee,{title:"Outbound Whitelist",actions:u&&e.jsx(F,{allow:"devOrAdmin",render:e.jsx(f,{"data-testid":"create-button-with-variables",variant:"primary",size:"sm",onClick:n.open}),children:"Add domains"})}),e.jsx(Dt,{className:"mb-6",columns:m,data:i,emptyText:e.jsx(Ia,{}),"data-testid":"whitelist"})]})}function li(){const{data:t}=gt({suspense:!0});return e.jsxs(vn,{children:[e.jsx(O,{index:!0,element:e.jsx(pa,{})}),e.jsxs(O,{path:":functionName",element:e.jsx(js,{functions:t}),children:[e.jsx(O,{index:!0,element:e.jsx(wn,{replace:!0,to:"general"})}),e.jsx(O,{path:"general",element:e.jsx(fs,{})}),e.jsx(O,{path:"environment-variables",element:e.jsx(ss,{})}),e.jsx(O,{path:"inbound-whitelist",element:e.jsx(Ea,{})}),e.jsx(O,{path:"outbound-whitelist",element:e.jsx(Va,{})}),e.jsx(O,{path:"playground",element:e.jsx(_s,{})}),e.jsx(O,{path:"versions",element:e.jsx(ba,{})})]}),e.jsx(O,{path:"*",element:e.jsx(kn,{})})]})}export{li as default};
21//# sourceMappingURL=index-ClZypKBN.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.