1import{j as e,P as p,H as K,B as v,ap as n,r as s,S as G,d as it,u as we,b as lt,g as y,i as me,n as J,I as w,T as ot}from"./index-Ba9Uy_0B.js";import{A as ct}from"./AppMenu-C2wOi_5e.js";import{S as dt}from"./SplitPaneLayout-BpcAu9GL.js";import{D as Se,j as ut,k as Ce,T as i,b4 as He,b5 as Be,C as ht,b6 as pt,b7 as mt,b8 as gt,b9 as yt,ba as ft,bb as xt,bc as jt,S as bt,bd as St,be as vt,bf as wt,bg as Ct,b2 as Tt,bh as kt,bi as At,b1 as _t,bj as Rt,bk as It,bl as Et,bm as Pt,x as Fe,bn as Ut,A as ve,r as Ot,bo as Gt}from"./Parameter-CIU04DnV.js";import{A as zt}from"./ActionRunnerMain-CV6USzP8.js";import{A as Nt}from"./api-OnuSWmem.js";import{a as _,F as E,D as ze}from"./index-B_UEhZpz.js";import{P as Ne}from"./Popup-swQNg5XR.js";import"./Placeholder-BDdAiu3I.js";import"./useMobile-Buw0TmOj.js";import"./index-CR0ZZmCe.js";import"./motion-Do0TwJaM.js";import"./StreamViewer-DCsztOU-.js";import"./SpreadsheetViewer-Dq0hDFNa.js";import"./ValidationsEditor-DIZOObhf.js";import"./index-CHs69FEm.js";import"./ace-CsNAEGat.js";import"./types-C-48g5o1.js";import"./StreamEChart-UMogpeU2.js";import"./ReactECharts-Dm1uMdFf.js";import"./FileViewer-CZgTJCIz.js";import"./Tab-BEOnIEuN.js";import"./JSONViewer-41NJKPjX.js";import"./papaparse.min-DP-rE8ZQ.js";import"./useAudioPosition-BKhzL7Ul.js";import"./StreamTriggerDataHandler-CqG8FtI2.js";import"./CustomTemplateModal-D8OmoLwI.js";import"./mode-css-ZyOVlraq.js";import"./mode-text-owca_3Io.js";import"./ActionInfo-BJu3O9fs.js";const Lt=r=>{const c=n.Type[r];return typeof c=="string"?c:"Credential"};function Dt({profiles:r=[],onCreate:c,onSelectProfile:u}){const d=r.length,f=r.slice(-5).reverse(),A=[{icon:"shopping cart",title:"Sell subscriptions and products",body:"Add a Stripe key so checkout on your site charges customers directly to your Stripe account. Recurring plans and one-time carts, both."},{icon:"mail",title:"Send email from your own domain",body:"SendGrid credentials let outbound email â signup confirmations, receipts, mailing lists â leave from your inbox instead of ours."},{icon:"cloud",title:"Read and write your own S3 bucket",body:"Bring AWS keys or a cross-account role so PlusScripts read files from â and write files back to â the bucket you control."},{icon:"microphone",title:"Send SMS with your Telnyx number",body:"Two-factor codes, confirmations, agent conversations â all originate from a phone number your customers already recognize."},{icon:"lightbulb",title:"Route AI calls through your own account",body:"Bring your own OpenAI or Anthropic key so PlusScripts and Agents invoke LLMs under your quota, not the platform's."},{icon:"globe",title:"Manage DNS and edge config",body:"Cloudflare credentials let a script or the domain manager add records, purge caches, and configure the edge for your zones."}];return e.jsx("div",{style:{background:"#fff",minHeight:"100%",width:"100%",overflowY:"auto"},children:e.jsxs("div",{style:{maxWidth:960,margin:"0 auto",padding:"2rem 1.5rem 3rem"},children:[e.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[e.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:64,height:64,borderRadius:"50%",background:"linear-gradient(135deg, #2185d0 0%, #6b46c1 100%)",color:"#fff",marginBottom:"1.25rem"},children:e.jsx(p,{name:"key",size:"large",style:{margin:0}})}),e.jsx(K,{as:"h1",style:{marginBottom:"0.5rem",fontSize:"2rem",letterSpacing:"-0.02em"},children:"Credential Wallet"}),e.jsx("p",{style:{color:"#555",fontSize:"1.05rem",lineHeight:1.55,maxWidth:640,margin:"0 auto"},children:"One safe place for the API keys and access tokens the platform uses on your behalf. Bring your own Stripe, SendGrid, AWS, OpenAI, Telnyx, and more â actions run under your account, on your quota, from your domain."}),e.jsxs("div",{style:{marginTop:"1.75rem",display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[e.jsxs(v,{primary:!0,size:"large",onClick:c,children:[e.jsx(p,{name:"plus"})," Add a Credential"]}),d>0&&e.jsxs("span",{style:{alignSelf:"center",color:"#888",fontSize:"0.9rem"},children:["or pick one of your ",e.jsx("strong",{children:d})," existing credential",d===1?"":"s"," from the menu â"]})]})]}),f.length>0&&u&&e.jsxs(e.Fragment,{children:[e.jsx(Se,{horizontal:!0,style:{color:"#999",fontSize:"0.75rem",letterSpacing:"0.15em",textTransform:"uppercase",margin:"2rem 0 1.5rem"},children:"Recent"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:"0.6rem",marginBottom:"0.5rem"},children:f.map(o=>e.jsxs("button",{type:"button",onClick:()=>o.object_id&&u(o.object_id),style:{display:"flex",alignItems:"center",gap:"0.6rem",padding:"0.7rem 0.9rem",border:"1px solid #eaeaea",borderRadius:8,background:"#fff",cursor:"pointer",textAlign:"left",font:"inherit"},children:[e.jsx(p,{name:"key",style:{margin:0,color:"#666"}}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontWeight:500,color:"#222"},children:o.label||"Unlabelled"}),e.jsx("span",{style:{color:"#888",fontSize:"0.8rem",flexShrink:0},children:Lt(o.credentialType)})]},o.object_id))})]}),e.jsx(Se,{horizontal:!0,style:{color:"#999",fontSize:"0.75rem",letterSpacing:"0.15em",textTransform:"uppercase",margin:"2rem 0 1.5rem"},children:"What you can do"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:"1rem"},children:A.map(o=>e.jsxs("div",{style:{border:"1px solid #eaeaea",borderRadius:8,padding:"1.15rem 1.15rem 1rem",background:"#fff",display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:36,height:36,borderRadius:8,background:"#f2f6fb",color:"#2185d0"},children:e.jsx(p,{name:o.icon,style:{margin:0}})}),e.jsx("div",{style:{fontWeight:600,fontSize:"0.98rem",color:"#222"},children:o.title}),e.jsx("div",{style:{fontSize:"0.88rem",color:"#666",lineHeight:1.5},children:o.body})]},o.title))}),e.jsx(Se,{horizontal:!0,style:{color:"#999",fontSize:"0.75rem",letterSpacing:"0.15em",textTransform:"uppercase",margin:"2.25rem 0 1.5rem"},children:"How we handle your secrets"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:"1rem"},children:[{icon:"lock",title:"Encrypted at rest",body:"Every credential is AES-256 encrypted before it lands in the database. The plaintext lives in memory only for the moment an action needs it."},{icon:"shield",title:"Never logged",body:"Diagnostic logs are scrubbed of credential values, ids, and encryption-header prefixes. What ends up on the log stream cannot be replayed."},{icon:"user secret",title:"Yours alone",body:"Ownership is enforced at the data layer â only you can read a credential you created. Shared editors on your site never see the secret behind an id."}].map(o=>e.jsxs("div",{style:{border:"1px solid #eaeaea",borderRadius:8,padding:"1.15rem 1.15rem 1rem",background:"#fafafa",display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:36,height:36,borderRadius:8,background:"#fff",border:"1px solid #eaeaea",color:"#555"},children:e.jsx(p,{name:o.icon,style:{margin:0}})}),e.jsx("div",{style:{fontWeight:600,fontSize:"0.98rem",color:"#222"},children:o.title}),e.jsx("div",{style:{fontSize:"0.88rem",color:"#666",lineHeight:1.5},children:o.body})]},o.title))})]})})}function Mt({credentialType:r}){const[c,u]=s.useState(null),d=s.useCallback(A=>u(A),[]),f=s.useMemo(()=>ut(r),[r]);return e.jsxs(G,{className:"credential-action-runner",style:c===0?{display:"none"}:void 0,children:[e.jsxs("h4",{style:{marginBottom:"0.25rem"},children:[e.jsx(p,{name:"play"})," Try it â what you can do with ",f]}),e.jsxs("p",{style:{color:"#666",marginTop:0},children:["Now that your ",f," credential is connected, you can run these actions with it."]}),e.jsx(zt,{restrictToCredentialType:r,on_receipt:"list",onVisibleActionCount:d})]})}const Le={USER:"Person",GROUP:"Group",RESOURCE:"Resource"},Wt={USER:"blue",GROUP:"violet",RESOURCE:"teal"};function Ht(r){if(r==null||r==="")return"â";const c=new Date(typeof r=="number"?r:Number(r)||r);return Number.isFinite(c.getTime())?c.toLocaleDateString():String(r)}function Bt({profile:r,typeLabel:c}){const u=Ce(),d=it(),{username:f,token:A}=we(),{hostname:o}=lt(),j=r.object_id,[T,Q]=s.useState(void 0),[W,X]=s.useState(),[k,z]=s.useState([]),[ce,R]=s.useState(!1),[I,P]=s.useState(),[U,H]=s.useState([]),[Z,$]=s.useState(!1),[B,te]=s.useState(),[F,se]=s.useState(void 0),[ne,N]=s.useState(!1),[O,L]=s.useState(void 0),[V,Y]=s.useState(!1),[re,q]=s.useState([]),[ae,D]=s.useState(!1),[x,ie]=s.useState("USER"),[le,h]=s.useState(""),[C,b]=s.useState(),[M,de]=s.useState(),[ue,a]=s.useState(""),[m,Te]=s.useState(""),[ke,Ae]=s.useState(""),[he,_e]=s.useState(!1),[Re,oe]=s.useState(),[ee,ge]=s.useState(),[Ie,Ee]=s.useState(!1),ye=async()=>
1{if(j){R(!0),P(void 0);try{z(await u.getCredentialGrants(j))}catch(t){z([]),P((t==null?void 0:t.message)||"Unable to load who has access")}finally{R(!1)}}},qe=async()=>{if(j){$(!0),te(void 0);try{H(await u.getCredentialUsage(j))}catch(t){H([]),te((t==null?void 0:t.message)||"Unable to load usage")}finally{$(!1)}}};s.useEffect(()=>{if(!j)return;let t=!1;return Q(void 0),X(void 0),u.canShareCredentials().then(l=>{t||Q(l)}).catch(l=>{t||(Q(!1),X((l==null?void 0:l.message)||"Unable to check whether you can share credentials"))}),ye(),qe(),()=>{t=!0}},[j]);const Pe=async()=>{if(!(F!==void 0||ne)){N(!0);try{let t=[];try{t=await d.getAllUserGroups(o)}catch{t=f?await d.getUserGroupsForUser(f):[]}se(t.filter(l=>!!l.object_id))}catch(t){se([]),J.error((t==null?void 0:t.message)||"Unable to load user groups")}finally{N(!1)}}},Ue=async()=>{if(O!==void 0||V||!f||!o)return;Y(!0);const t=[],l=async(g,at)=>{try{const be=await at();return Array.isArray(be)?be:[]}catch{return t.push(g),[]}},[S,et,tt,st,nt]=await Promise.all([l("collections",()=>d.getUserCollections(o,f)),l("streams",()=>d.getUserStreams(o,f)),l("agents",()=>Nt.list(A||"",o,f)),l("APIs",()=>d.getUserAPIs(f)),l("websites",()=>d.listWebsitesV2())]),rt=[...S.map(g=>({object_id:g.object_id,label:g.label||g.object_id,kind:"Collection"})),...et.map(g=>({object_id:g.object_id,label:g.title||g.label||g.object_id,kind:"Stream"})),...tt.map(g=>({object_id:g.object_id,label:g.label||g.short_code||g.object_id,kind:"Agent"})),...st.map(g=>({object_id:g.object_id,label:g.label||g.short_code||g.object_id,kind:"API"})),...nt.map(g=>({object_id:g.object_id,label:g.label||g.uniqueId||g.object_id,kind:"Website"}))];L(gt(rt,f,j)),q(t),Y(!1)};s.useEffect(()=>{k.some(t=>t.grantee_type==="GROUP")&&Pe(),k.some(t=>t.grantee_type==="RESOURCE")&&Ue()},[k]);const Je=t=>{var l;return((l=F==null?void 0:F.find(S=>S.object_id===t))==null?void 0:l.label)||t},Oe=t=>O==null?void 0:O.find(l=>l.object_id===t),fe=(t,l)=>{if(t==="GROUP")return Je(l);if(t==="RESOURCE"){const S=Oe(l);return S?"".concat(S.kind,": ").concat(S.label):l}return l},Ke=s.useMemo(()=>(F||[]).map(t=>({key:t.object_id,value:t.object_id,text:t.label||t.object_id})),[F]),Qe=s.useMemo(()=>(O||[]).map(t=>({key:t.object_id,value:t.object_id,text:"".concat(t.kind,": ").concat(t.label)})),[O]),xe=M?Oe(M):void 0,Xe=()=>{ie("USER"),h(""),b(void 0),de(void 0),a(""),Te(""),Ae(""),oe(void 0)},Ze=()=>{Xe(),D(!0)},je=t=>{ie(t),oe(void 0),t==="GROUP"&&Pe(),t==="RESOURCE"&&Ue()},pe=x==="USER"?le.trim():x==="GROUP"?C||"":M||"",Ge=async()=>{if(!j)return;if(oe(void 0),!pe){oe(x==="USER"?"Enter an email address.":"Pick a ".concat(Le[x].toLowerCase(),"."));return}const t=yt(m);if(t===void 0){oe("The expiry date is not a valid date.");return}try{_e(!0),await u.createCredentialGrant(j,{grantee:{type:x,id:pe},expires_at:t,allowed_action_ids:ue,label:ke.trim()||void 0}),J.success('Shared "'.concat(r.label,'" with ').concat(fe(x,pe))),D(!1),await ye()}catch(l){oe((l==null?void 0:l.message)||"Unable to share this credential")}finally{_e(!1)}},$e=async()=>{if(!(!j||!ee))try{Ee(!0),await u.revokeCredentialGrant(j,{type:String(ee.grantee_type),id:ee.grantee_id})?J.success("Access revoked"):J.error("That access was already removed"),ge(void 0),await ye()}catch(t){J.error((t==null?void 0:t.message)||"Unable to revoke access")}finally{Ee(!1)}};return j?e.jsxs(G,{className:"credential-sharing",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",marginBottom:"0.75rem"},children:[e.jsxs(K,{as:"h4",style:{margin:0},children:[e.jsx(p,{name:"share alternate"})," Sharing"]}),T&&e.jsxs(v,{size:"small",color:"teal",onClick:Ze,children:[e.jsx(p,{name:"plus"}),"Share"]})]}),e.jsx("p",{style:{color:"#666",marginTop:0},children:"People, groups and resources you share this credential with can use it in automations. They never see the secret, and you can revoke access at any time."}),T===!1&&e.jsx(y,{info:!0,children:W||"Credential sharing is not enabled for your user group. Ask a site admin."}),e.jsx(K,{as:"h5",style:{marginTop:"1rem"},children:"People with access"}),I?e.jsx(y,{negative:!0,size:"small",children:I}):ce?e.jsx("p",{style:{color:"#888"},children:"Loadingâ¦"}):k.length===0?e.jsx("p",{style:{color:"#888",fontStyle:"italic"},children:"Only you can use this credential."}):e.jsxs(i,{compact:!0,unstackable:!0,size:"small",children:[e.jsx(i.Header,{children:e.jsxs(i.Row,{children:[e.jsx(i.HeaderCell,{children:"Who"}),e.jsx(i.HeaderCell,{children:"Actions allowed"}),e.jsx(i.HeaderCell,{children:"Expires"}),e.jsx(i.HeaderCell,{children:"Shared"}),e.jsx(i.HeaderCell,{})]})}),e.jsx(i.Body,{children:k.map(t=>e.jsxs(i.Row,{children:[e.jsxs(i.Cell,{children:[e.jsx(me,{size:"mini",color:Wt[String(t.grantee_type)]||"grey",style:{marginRight:"0.5rem"},children:Le[String(t.grantee_type)]||String(t.grantee_type)}),e.jsx("span",{style:{wordBreak:"break-all"},children:fe(String(t.grantee_type),t.grantee_id)}),t.label&&e.jsx("div",{style:{color:"#888",fontSize:"0.85em"},children:t.label})]}),e.jsx(i.Cell,{children:He(t.constraints)}),e.jsx(i.Cell,{children:Be(t.expires_at)}),e.jsxs(i.Cell,{children:[Ht(t.granted_at),t.granted_by&&t.granted_by!==f&&e.jsxs("div",{style:{color:"#888",fontSize:"0.85em"},children:["by ",t.granted_by]})]}),e.jsx(i.Cell,{collapsing:!0,children:e.jsxs(v,{basic:!0,size:"mini",color:"red",title:"Revoke access",onClick:()=>ge(t),children:[e.jsx(p,{name:"ban"}),"Revoke"]})})]},t.object_id||"".concat(t.grantee_type,":").concat(t.grantee_id)))})]}),e.jsx(K,{as:"h5",style:{marginTop:"1.5rem"}
1,children:"Usage by people you shared with"}),B?e.jsx(y,{negative:!0,size:"small",children:B}):Z?e.jsx("p",{style:{color:"#888"},children:"Loadingâ¦"}):U.length===0?e.jsx("p",{style:{color:"#888",fontStyle:"italic"},children:"No one has used this credential through a share yet."}):e.jsxs(i,{compact:!0,unstackable:!0,size:"small",children:[e.jsx(i.Header,{children:e.jsxs(i.Row,{children:[e.jsx(i.HeaderCell,{children:"Day"}),e.jsx(i.HeaderCell,{children:"Used by"}),e.jsx(i.HeaderCell,{children:"Action"}),e.jsx(i.HeaderCell,{textAlign:"right",children:"Uses"})]})}),e.jsx(i.Body,{children:U.map((t,l)=>e.jsxs(i.Row,{children:[e.jsx(i.Cell,{children:t.day}),e.jsx(i.Cell,{style:{wordBreak:"break-all"},children:t.grantee}),e.jsx(i.Cell,{style:{wordBreak:"break-all"},children:t.action_id||"â"}),e.jsx(i.Cell,{textAlign:"right",children:t.count})]},"".concat(t.day,"|").concat(t.grantee,"|").concat(t.action_id,"|").concat(l)))})]}),e.jsx(ht,{open:!!ee,header:"Revoke access",content:ee?"".concat(fe(String(ee.grantee_type),ee.grantee_id),' will no longer be able to use "').concat(r.label,'". Automations that rely on it will fail.'):"",confirmButton:e.jsx(v,{negative:!0,loading:Ie,disabled:Ie,children:"Revoke"}),onCancel:()=>ge(void 0),onConfirm:$e,size:"tiny"}),e.jsxs(_,{open:ae,onClose:()=>!he&&D(!1),size:"small",children:[e.jsxs(_.Header,{children:[e.jsx(p,{name:"share alternate"}),' Share "',r.label,'"']}),e.jsxs(_.Content,{children:[e.jsxs(E,{onSubmit:Ge,children:[e.jsxs(E.Group,{inline:!0,children:[e.jsx("label",{children:"Share with"}),e.jsx(E.Radio,{label:"A person",checked:x==="USER",onChange:()=>je("USER")}),e.jsx(E.Radio,{label:"A group",checked:x==="GROUP",onChange:()=>je("GROUP")}),e.jsx(E.Radio,{label:"A resource",checked:x==="RESOURCE",onChange:()=>je("RESOURCE")})]}),x==="USER"&&e.jsx(E.Input,{label:"Email address",type:"email",placeholder:"[email protected]",value:le,onChange:(t,l)=>{var S;return h(String((S=l.value)!=null?S:""))}}),x==="GROUP"&&e.jsxs(E.Field,{children:[e.jsx("label",{children:"User group"}),e.jsx(ze,{fluid:!0,selection:!0,search:!0,loading:ne,placeholder:"Select a groupâ¦",options:Ke,value:C,noResultsMessage:ne?"Loadingâ¦":"No user groups found.",onChange:(t,l)=>b(l.value)})]}),x==="RESOURCE"&&e.jsxs(E.Field,{children:[e.jsx("label",{children:"Resource"}),e.jsx(ze,{fluid:!0,selection:!0,search:!0,loading:V,placeholder:"Select one of your collections, streams, agents, APIs or websitesâ¦",options:Qe,value:M,noResultsMessage:V?"Loadingâ¦":"You have no resources on this site.",onChange:(t,l)=>de(l.value)}),re.length>0&&e.jsxs("div",{style:{color:"#a07000",fontSize:"0.85em",marginTop:"0.25rem"},children:["Could not load your ",re.join(", "),"."]})]}),e.jsx(E.Input,{label:"Only allow these actions (optional)",placeholder:"Comma-separated action ids. Leave empty to allow any action.",value:ue,onChange:(t,l)=>{var S;return a(String((S=l.value)!=null?S:""))}}),e.jsx(E.Input,{label:"Expires (optional)",type:"date",min:pt(),value:m,onChange:(t,l)=>{var S;return Te(String((S=l.value)!=null?S:""))}}),e.jsx(E.Input,{label:"Note (optional)",placeholder:"Why you shared it, for your own records",maxLength:200,value:ke,onChange:(t,l)=>{var S;return Ae(String((S=l.value)!=null?S:""))}})]}),e.jsxs(y,{warning:!0,children:[e.jsx(y.Header,{children:"What this allows"}),e.jsx("p",{children:mt(x,xe?"".concat(xe.kind.toLowerCase(),' "').concat(xe.label,'"'):void 0,c)})]}),Re&&e.jsx(y,{negative:!0,children:Re})]}),e.jsxs(_.Actions,{children:[e.jsx(v,{onClick:()=>D(!1),disabled:he,children:"Cancel"}),e.jsx(v,{color:"teal",loading:he,disabled:he||!pe,onClick:Ge,children:"Share"})]})]})]}):null}const Ft=[],Ve={[n.Type.AWS]:"Amazon Web Services",[n.Type.OpenAI]:"OpenAI",[n.Type.Discord]:"Discord",[n.Type.SendGrid]:"SendGrid",[n.Type.ElasticSearch]:"Elasticsearch",[n.Type.GCP]:"Google Cloud Platform",[n.Type.Google]:"Google OAuth",[n.Type.Stripe]:"Stripe",[n.Type.Telnyx]:"Telnyx",[n.Type.Printful]:"Printful",[n.Type.Anthropic]:"Anthropic",[n.Type.Cloudflare]:"Cloudflare",[n.Type.FlyIO]:"Fly.io",[n.Type.Slack]:"Slack",[n.Type.GooglePay]:"Google Pay",[n.Type.PayPal]:"PayPal",[n.Type.HumeAI]:"Hume AI"},Ye={[n.Type.AWS]:"/icons/wallet/aws.svg",[n.Type.OpenAI]:"/icons/wallet/openai.svg",[n.Type.Discord]:"/icons/wallet/discord.svg",[n.Type.SendGrid]:"/icons/wallet/sendgr
1id.svg",[n.Type.ElasticSearch]:"/icons/wallet/elastic.svg",[n.Type.GCP]:"/icons/wallet/gcp.svg",[n.Type.Google]:"/icons/wallet/google.svg",[n.Type.Stripe]:"/icons/wallet/stripe.svg",[n.Type.Telnyx]:"/icons/wallet/telnyx.svg",[n.Type.Printful]:"/icons/wallet/printful.svg",[n.Type.Anthropic]:"/icons/wallet/anthropic.svg",[n.Type.Cloudflare]:"/icons/wallet/cloudflare.svg",[n.Type.FlyIO]:"/icons/wallet/flyio.svg",[n.Type.Slack]:"/icons/wallet/slack.svg",[n.Type.GooglePay]:"/icons/wallet/googlepay.svg",[n.Type.PayPal]:"/icons/wallet/paypal.svg",[n.Type.HumeAI]:"/icons/wallet/hume.svg"};function Vt(r,c=6){return r?r.length<=c?"â¢â¢â¢â¢"+r:"â¢â¢â¢â¢â¢â¢â¢â¢"+r.slice(-c):"â¢â¢â¢â¢â¢â¢â¢â¢"}async function Yt(r){try{return await navigator.clipboard.writeText(r),!0}catch{return!1}}function qt({label:r,value:c,showLast:u=6}){const[d,f]=s.useState(!1),[A,o]=s.useState(!1),j=async()=>{c&&await Yt(c)&&(o(!0),setTimeout(()=>o(!1),2e3))},T=d?c:Vt(c,u);return e.jsxs("div",{className:"masked-value-row",children:[e.jsx("span",{className:"masked-value-label",children:r}),e.jsx("code",{className:"masked-value-display",children:T||"Not set"}),e.jsxs("div",{className:"masked-value-actions",children:[e.jsx(Ne,{content:d?"Hide":"Reveal",trigger:e.jsx(v,{icon:d?"eye slash":"eye",size:"mini",basic:!0,onClick:()=>f(!d)})}),e.jsx(Ne,{content:A?"Copied!":"Copy",trigger:e.jsx(v,{icon:A?"check":"copy",size:"mini",basic:!0,disabled:!c,onClick:j})})]})]})}function Jt({profile:r,handlers:c=[ft,xt,jt,bt,St,vt,wt,Ct,Tt,kt,At,_t,Rt,It,Et,...Ft],onDelete:u,onUpdate:d,onClose:f}){const A=Ce(),{username:o,metadata:j}=we(),{object_id:T,label:Q,credentialType:W,payload:X}=r,k=c.find(a=>a.credentialType===W),z=T!==void 0,ce=(j==null?void 0:j.account_type)==="admin",R=z&&!!o&&Pt(T)===o,[I,P]=s.useState(!1),[U,H]=s.useState(!1),[Z,$]=s.useState("untested"),[B,te]=s.useState(null),[F,se]=s.useState(!1),[ne,N]=s.useState(!1),[O,L]=s.useState(!1),[V,Y]=s.useState(),[re,q]=s.useState(!1),[ae,D]=s.useState(),[x,ie]=s.useState(!1),le=s.useMemo(()=>k&&X?k.unserialize(X):new Map,[k,X]),h=Ve[W]||"Unknown",C=Ye[W]||"/icons/wallet/unknown.svg",b=async a=>{if(o&&a)try{P(!0);const m=await A.deleteCredentialProfile(o,a);u&&u(m)}catch(m){console.error(m.message||"Unable to delete credential"),J.error("Unable to delete credential")}finally{P(!1)}},M=async()=>{if(o&&T)try{H(!0),D(void 0);const a=await A.testCredentialProfile(o,T);if((a==null?void 0:a.success)===!1)throw new Error(a.message||"Connection test failed");Y(a),$("success"),te(new Date),L(!0)}catch(a){console.error(a.message||"Unable to test credential"),D(a.message||"Unable to test credential"),Y(void 0),$("failed"),te(new Date),q(!0)}finally{H(!1)}},de=a=>{if(!a)return[];const m=[];return a.toLowerCase().includes("decrypt")&&(m.push("The encryption key may be missing or incorrect in the server configuration."),m.push("This credential may have been saved with a different encryption key."),m.push("Try deleting and re-creating this credential.")),(a.toLowerCase().includes("unauthorized")||a.toLowerCase().includes("401"))&&(m.push("The API key or credentials may be invalid or expired."),m.push("Check that you're using the correct key type (test vs live).")),(a.toLowerCase().includes("network")||a.toLowerCase().includes("fetch"))&&(m.push("Check your internet connection."),m.push("The service endpoint may be temporarily unavailable.")),m.length===0&&(m.push("Try editing the credential and re-saving it."),m.push("Check the server logs for more details.")),m},ue=a=>{var m;return a?a.Account&&a.Arn?e.jsxs(y,{positive:!0,children:[e.jsxs(y.Header,{children:[e.jsx(p,{name:"check circle"})," Connection Successful"]}),e.jsxs(y.List,{children:[e.jsxs(y.Item,{children:["Account ID: ",e.jsx("strong",{children:a.Account})]}),e.jsxs(y.Item,{children:["User ARN: ",e.jsx("code",{children:a.Arn})]}),a.UserId&&e.jsxs(y.Item,{children:["User ID: ",a.UserId]})]})]}):a.id&&a.object==="account"?e.jsxs(y,{positive:!0,children:[e.jsxs(y.Header,{children:[e.jsx(p,{name:"check circle"})," Connection Successful"]}),e.jsxs(y.List,{children:[e.jsxs(y.Item,{children:["Account: ",e.jsx("strong",{children:((m=a.business_profile)==null?void 0:m.name)||a.id})]}),e.jsxs(y.Item,{children:["Type: ",a.type]})]})]}):e.jsxs(y,{positive:!0,children:[e.jsxs(y.Header,{children:[e.jsx(p,{name:"check circle"})," Connection Successful"]}),e.jsx("p",{children:"Your credentials are valid and working."}),Object.keys(a).length>0&&e.jsx("pre",{style:{fontSize:"11px",maxHeight:"150px",overflow:"auto"},children:JSON.stringify(a,null,2)})]}):null};return Z==="success"?"Tested successfully".concat(B?" at ".concat(B.toLocaleTimeString()):""):Z==="failed"&&"Test failed".concat(B?" at ".concat(B.toLocaleTimeString()):""),e.jsxs("section",{className:"credential-viewer",children:[e.jsxs(_,{open:O,onClose:()=>L(!1),size:"small",children:[e.jsxs(_.Header,{children:[e.jsx(p,{name:"check circle",color:"green"})," Connection Test Result"]}),e.jsx(_.Content,{children:ue(V)}),e.jsx(_.Actions,{children:e.jsx(v,{primary:!0,onClick:()=>L(!1),children:"Done"})})]}),e.jsxs(_,{open:re,onClose:()=>q(!1),size:"small",children:[e.jsxs(_.Header,{children:[e.jsx(p,{name:"warning sign",color:"red"})," Connection Test Failed"]}),e.jsxs(_.Content,{children:[e.jsxs(y,{negative:!0,children:[e.jsx(y.Header,{children:"Error"}),e.jsx("p",{children:ae})]}),e.jsx(K,{as:"h4",children:"Troubleshooting Tips:"}),e.jsx(y,{info:!0,children:e.jsx(y.List,{children:de(ae).map((a,m)=>e.jsx(y.Item,{children:a},m))})})]}),e.jsxs(_.Actions,{children:[e.jsx(v,{onClick:()=>q(!1),children:"Close"}),e.jsxs(v,{color:"blue",onClick:()=>{q(!1),N(!0)},children:[e.jsx(p,{name:"edit"})," Edit Credential"]})]})]}),e.jsx(Fe,{trigger:null,header:"Edit Credential",editButtonText:"Update",openModal:ne,onOpenModal:N,profile:r,onUpdate:d}),e.jsx(Ut,{pending:I,openModal:F,onOpenModal:se,trigger:null,profileId:T,label:Q,onDelete:b}),e.jsx(G,{className:"credential-header",children:e.jsxs("div",{className:"credential-header-content",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",flex:1,minWidth:0},children:[e.jsx("div",{className:"credential-icon",children:e.jsx(w,{src:C,style:{width:"2.5rem",height:"2.5rem"}})}),e.jsxs("div",{className:"credential-info",style:{minWidth:0},children:[e.jsx(K,{as:"h2",style:{margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Q}),e.jsx(me,{basic:!0,color:"grey",size:"small",style:{marginTop:"0.25rem"},children:h})]})]}),f&&e.jsx(v,{basic:!0,icon:!0,size:"small",title:"Close this credential and return to the Wallet home",onClick:f,style:{flexShrink:0},children:e.jsx(p,{name:"close"})})]})}),e.jsxs(G,{className:"credential-values",children:[e.jsxs(K,{as:"h4",style:{marginBottom:"1rem"},children:[e.jsx(p,{name:"key"})," Stored Credentials"]}),e.jsx("div",{className:"masked-values-container",children:k==null?void 0:k.params.map(a=>{var m;return e.jsx(qt,{label:a.label||a.var_name,value:(m=le.get(a.var_name))==null?void 0:m.sval},a.var_name)})})]}),e.jsxs(G,{className:"credential-actions",children:[e.jsxs(v,{primary:!0,disabled:!z,loading:U,onClick:M,children:[e.jsx(p,{name:"plug"}),"Test Connection"]}),e.jsxs(v,{disabled:!z,onClick:()=>N(!0),children:[e.jsx(p,{name:"edit"}),"Edit"]}),e.jsxs(v,{basic:!0,disabled:!z,loading:I,color:"red",onClick:()=>se(!0),children:[e.jsx(p,{name:"trash"}),"Delete"]})]}),z&&e.jsx(Mt,{credentialType:W,credentialId:T}),R&&e.jsx(Bt,{profile:r,typeLabel:h}),k&&e.jsx(G,{className:"credential-instructions",children:e.jsxs(ve,{children:[e.jsxs(ve.Title,{active:x,onClick:()=>ie(!x),style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{children:[e.jsx(p,{name:"dropdown"}),e.jsx(p,{name:"book"}
1)," Setup Instructions"]}),ce&&e.jsxs(v,{basic:!0,size:"mini",onClick:a=>{a.stopPropagation(),J.success("Editing instructions coming soon")},children:[e.jsx(p,{name:"edit"}),"Edit"]})]}),e.jsx(ve.Content,{active:x,children:e.jsx("div",{className:"markdown-content",style:{marginTop:"1rem"},children:e.jsx(ot,{children:k.description})})})]})})]})}const Kt={USER:"You, directly",GROUP:"A user group you belong to"};function Qt({credential:r,onClose:c}){const u=Ve[r.credentialType]||"Unknown",d=Ye[r.credentialType]||"/icons/wallet/unknown.svg";return e.jsxs("section",{className:"credential-viewer",children:[e.jsx(G,{className:"credential-header",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",flex:1,minWidth:0},children:[e.jsx("div",{className:"credential-icon",children:e.jsx(w,{src:d,style:{width:"2.5rem",height:"2.5rem"}})}),e.jsxs("div",{className:"credential-info",style:{minWidth:0},children:[e.jsx(K,{as:"h2",style:{margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.label||"(unnamed)"}),e.jsx(me,{basic:!0,color:"grey",size:"small",style:{marginTop:"0.25rem"},children:u}),e.jsxs(me,{color:"blue",size:"small",style:{marginTop:"0.25rem"},children:[e.jsx(p,{name:"share alternate"})," Shared with you"]})]})]}),c&&e.jsx(v,{basic:!0,icon:!0,size:"small",title:"Close this credential and return to the Wallet home",onClick:c,style:{flexShrink:0},children:e.jsx(p,{name:"close"})})]})}),e.jsxs(G,{children:[e.jsx(i,{definition:!0,compact:!0,unstackable:!0,children:e.jsxs(i.Body,{children:[e.jsxs(i.Row,{children:[e.jsx(i.Cell,{width:5,children:"Owner"}),e.jsx(i.Cell,{style:{wordBreak:"break-all"},children:r.owner_username||"â"})]}),e.jsxs(i.Row,{children:[e.jsx(i.Cell,{children:"Type"}),e.jsx(i.Cell,{children:u})]}),e.jsxs(i.Row,{children:[e.jsx(i.Cell,{children:"Shared with"}),e.jsx(i.Cell,{children:Kt[String(r.grantee_type)]||String(r.grantee_type||"â")})]}),e.jsxs(i.Row,{children:[e.jsx(i.Cell,{children:"Actions allowed"}),e.jsx(i.Cell,{children:He(r.constraints)})]}),e.jsxs(i.Row,{children:[e.jsx(i.Cell,{children:"Expires"}),e.jsx(i.Cell,{children:Be(r.expires_at)})]})]})}),e.jsx(y,{info:!0,size:"small",children:"You can pick this credential in your own automations. You cannot see its secret, and only the owner can change, rotate or delete it or stop sharing it."})]})]})}var De;const Xt=((De=void 0)==null?void 0:De.toLowerCase())==="true",Me=e.jsx(w,{src:"/icons/wallet/unknown.svg",floated:"right",style:{width:"1.2rem"}}),Zt=e.jsx(w,{src:"/icons/wallet/openai.svg",floated:"right",style:{width:"1.2rem"}}),$t=e.jsx(w,{src:"/icons/wallet/aws.svg",floated:"right",style:{width:"1.3rem"}}),es=e.jsx(w,{src:"/icons/wallet/discord.svg",floated:"right",style:{width:"1.3rem"}}),ts=e.jsx(w,{src:"/icons/wallet/sendgrid.svg",floated:"right",style:{width:"1.3rem"}}),ss=e.jsx(w,{src:"/icons/wallet/elastic.svg",floated:"right",style:{width:"1.3rem"}}),ns=e.jsx(w,{src:"/icons/wallet/gcp.svg",floated:"right",style:{width:"1.3rem"}}),rs=e.jsx(w,{src:"/icons/wallet/google.svg",floated:"right",style:{width:"1.3rem"}}),as=e.jsx(w,{src:"/icons/wallet/stripe.svg",floated:"right",style:{width:"1.3rem"}}),is=e.jsx(w,{src:"/icons/wallet/telnyx.svg",floated:"right",style:{width:"1.3rem"}}),ls=e.jsx(w,{src:"/icons/wallet/printful.svg",floated:"right",style:{width:"1.3rem"}}),os=e.jsx(w,{src:"/icons/wallet/anthropic.svg",floated:"right",style:{width:"1.3rem"}}),cs=e.jsx(w,{src:"/icons/wallet/cloudflare.svg",floated:"right",style:{width:"1.3rem"}}),ds=e.jsx(w,{src:"/icons/wallet/slack.svg",floated:"right",style:{width:"1.3rem"}}),us=e.jsx(w,{src:"/icons/wallet/googlepay.svg",floated:"right",style:{width:"1.3rem"}}),hs=e.jsx(w,{src:"/icons/wallet/paypal.svg",floated:"right",style:{width:"1.3rem"}}),We={[n.Type.AWS]:$t,[n.Type.OpenAI]:Zt,[n.Type.Discord]:es,[n.Type.SendGrid]:ts,[n.Type.ElasticSearch]:ss,[n.Type.GCP]:ns,[n.Type.Google]:rs,[n.Type.Stripe]:as,[n.Type.Telnyx]:is,[n.Type.Printful]:ls,[n.Type.Anthropic]:os,[n.Type.Cloudflare]:cs,[n.Type.Slack]:ds,[n.Type.GooglePay]:us,[n.Type.PayPal]:hs}
1;function ps(r){const c=(r||[]).map(d=>d.allowed_credential_types).filter(d=>Array.isArray(d)&&d.length>0);if(c.length===0)return;const u=new Set;for(const d of c)for(const f of d)u.add(f);return Array.from(u)}function Fs(r){const c=Ce(),{username:u}=we(),{userGroups:d}=Ot(),f=ps(d),[A,o]=s.useState(!1),[j,T]=s.useState(!1),[Q,W]=s.useState(!1),[X,k]=s.useState(),[z,ce]=s.useState(new Map),[R,I]=s.useState([]),[P,U]=s.useState(void 0),[H,Z]=s.useState(!0),[$,B]=s.useState(!1),[te,F]=s.useState(!1),[se,ne]=s.useState(!1),[N,O]=s.useState([]);R&&R.length>0;const L=R.find(h=>h.object_id===P),V=L?void 0:N.find(h=>h.object_id===P);s.useEffect(()=>{u&&(async C=>{Z(!0),c.getCredentialProfiles(C).then(b=>{I(b)}).catch(b=>{I([]),J.error(b.message||"Failed to get Wallet profiles")}).finally(()=>{Z(!1)})})(u)},[u]),s.useEffect(()=>{u&&c.getSharedWithMe().then(O).catch(h=>{O([]),Xt&&console.error(h.message||"Failed to get shared credentials")})},[u]);const Y=h=>{I(C=>C.find(b=>b.object_id===h.object_id)?C.map(b=>b.object_id===h.object_id?h:b):[...C,h]),U(h.object_id)},re=h=>{I(C=>C.filter(b=>b.object_id!==h.object_id)),U(void 0)},q=R.map(({object_id:h,credentialType:C,label:b})=>({id:h,content:We[C]||Me,label:b})),ae=new Set(R.map(h=>h.object_id)),D=N.filter(({object_id:h})=>h&&!ae.has(h)).map(({object_id:h,credentialType:C,label:b,owner_username:M})=>({id:h,content:We[C]||Me,label:b||"(unnamed)",description:M?"from ".concat(M):void 0,section:"Shared with me"})),x=()=>{U(void 0)},ie=e.jsx(ct,{loading:H,menuItems:[...q,...D],selectedItemId:P,setSelectedItemId:U,header:e.jsxs(s.Fragment,{children:[e.jsx(Fe,{loading:$,trigger:e.jsx(v,{icon:!0,children:e.jsx(p,{name:"plus"})}),header:"Add a new Credential",editButtonText:"Create",openModal:A,onOpenModal:o,onUpdate:Y,onRequestAwsCrossAccount:()=>T(!0),allowedCredentialTypes:f}),e.jsx(Gt,{open:j,onClose:()=>T(!1),onCreated:()=>{u&&c.getCredentialProfiles(u).then(I).catch(()=>{})}})]})}),le=L?e.jsx(G,{className:"profile-view",children:e.jsx(Jt,{profile:L,onDelete:re,onUpdate:Y,onClose:x})}):V?e.jsx(G,{className:"profile-view",children:e.jsx(Qt,{credential:V,onClose:x})}):e.jsx(Dt,{profiles:R,onCreate:()=>o(!0),onSelectProfile:U});return e.jsx(dt,{className:"wallet-app",menu:ie,content:le,hasSelection:!!P,onBack:x,menuLoading:H,menuWidth:{mobile:16,tablet:6,computer:4},collapsibleMenu:!0})}export{Fs as default};
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.