1import{z as A,r as C,u as ee,t as se,w as ae,j as e,C as R,A as O,g as te,b1 as U,b2 as T,B as w,I as S,F as j,a as D,b as V,cx as re,Q as y,aM as I,aN as M,bi as P,bm as m,cn as N,ag as b,aG as q,O as ne,an as ie,bp as H,bf as $,bg as z,bh as E,bj as u,bk as L,bl as F,M as K,h as le,fH as ce,d as G,bT as _,aI as B,hb as oe,bF as de,i as he,k as pe,R as Q,H as X,bE as xe}from"./index-YNsGwUAq.js";import{P as me}from"./PageHeader-Bi4cCaHa.js";import{T as ue,a as je,b as J,c as W}from"./Tabs-xwZ8ZMbY.js";import{c as ge,d as ye,e as fe,f as Se}from"./mutations-D-K11mPc.js";import{a as f}from"./ShareSecretForm-CHCpK0Wm.js";import{E as Y}from"./EmptyState-UgnfbzEj.js";import{P as Z}from"./Pagination-BqcXA8QT.js";import{b as be,c as ve}from"./queries-DuFvqAw0.js";import{A as Ce}from"./AddShareSecretModal-C5AbaIxt.js";import{u as we}from"./useTranslation-B41oWJHe.js";import"./Switch-D4EQ5acA.js";const Ne=A.object({name:A.string().optional(),accessType:A.nativeEnum(f).default(f.Anyone).optional(),expiresIn:A.string()}),qe=[{label:"5 min",value:5*60*1e3},{label:"30 min",value:30*60*1e3},{label:"1 hour",value:60*60*1e3},{label:"1 day",value:24*60*60*1e3},{label:"7 days",value:7*24*60*60*1e3},{label:"14 days",value:14*24*60*60*1e3},{label:"30 days",value:30*24*60*60*1e3}],Ae=()=>{const[s,r]=C.useState(""),[,n,t]=ee({initialState:"Copy to clipboard"}),{mutateAsync:c}=ge(),{control:i,reset:a,handleSubmit:p,formState:{isSubmitting:h}}=se({resolver:ae(Ne)}),l=async({name:o,accessType:d,expiresIn:x})=>{const g=new Date(new Date().getTime()+Number(x));try{const{id:v}=await c({name:o,accessType:d,expiresAt:g}),k=`${window.location.origin}/secret-request/secret/${v}`;r(k),a(),navigator.clipboard.writeText(k),t("secret"),y({text:"Shared secret link copied to clipboard.",type:"success"})}catch(v){console.error(v),y({text:"Failed to create a shared secret.",type:"error"})}};return s?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mr-2 flex items-center justify-end rounded-md bg-white/[0.05] p-2 text-base text-gray-400",children:[e.jsx("p",{className:"mr-4 break-all",children:s}),e.jsx(S,{ariaLabel:"copy icon",colorSchema:"secondary",className:"group relative ml-2",onClick:()=>{navigator.clipboard.writeText(s),t("Copied")},children:e.jsx(j,{icon:n?D:V})})]}),e.jsx(w,{className:"mt-4 w-full bg-mineshaft-700 py-3 text-bunker-200",colorSchema:"primary",variant:"outline_bg",size:"sm",onClick:()=>r(""),rightIcon:e.jsx(j,{icon:re,className:"pl-2"}),children:"Request Another Secret"})]}):e.jsxs("form",{onSubmit:p(l),children:[e.jsx(R,{control:i,name:"name",render:({field:o,fieldState:{error:d}})=>e.jsx(O,{label:"Name (Optional)",isError:!!d,errorText:d==null?void 0:d.message,children:e.jsx(te,{...o,placeholder:"API Key",type:"text"})})}),e.jsx(R,{control:i,name:"expiresIn",defaultValue:"3600000",render:({field:{onChange:o,...d},fieldState:{error:x}})=>e.jsx(O,{label:"Expires In",errorText:x==null?void 0:x.message,tooltipText:"Select for how long someone is able to input the secret. If a secret is shared with you in time, it will remain available to you, even after the expiration.",isError:!!x,children:e.jsx(U,{defaultValue:d.value,...d,onValueChange:g=>o(g),className:"w-full",children:qe.map(({label:g,value:v})=>e.jsx(T,{value:String(v||""),children:g},g))})})}),e.jsx(R,{control:i,name:"accessType",defaultValue:f.Organization,render:({field:{onChange:o,...d},fieldState:{error:x}})=>e.jsx(O,{tooltipText:"Select who is able to input the secret",label:"General Access",errorText:x==null?void 0:x.message,isError:!!x,children:e.jsxs(U,{defaultValue:d.value,...d,onValueChange:g=>o(g),className:"w-full",children:[e.jsx(T,{value:f.Anyone,children:"Anyone"}),e.jsx(T,{value:f.Organization,children:"People within your organization"})]})})}),e.jsx(w,{className:"mt-4",size:"sm",type:"submit",isLoading:h,isDisabled:h,children:"Create Request Link"})]})},Pe=({popUp:s,handlePopUpToggle:r})=>{var n;return e.jsx(I,{isOpen:(n=s==null?void 0:s.createSecretRequest)==null?void 0:n.isOpen,onOpenChange:t=>{r("createSecretRequest",t)},children:e.jsx(M,{title:"Request a Secret",subTitle:"Securely request one off secrets from your team or people outside your organization.",children:e.jsx(Ae,{})})})},Re=({row:s,handlePopUpOpen:r})=>{const{mutateAsync:n,isPending:t}=ye();let c=!1;return s.expiresAt!==null&&new Date(s.expiresAt)<new Date&&(c=!0),e.jsxs(P,{children:[e.jsx(m,{children:s.name?`${s.name}`:"-"}),e.jsx(m,{children:c&&!s.encryptedSecret?e.jsx(N,{variant:"danger",children:"Expired"}):e.jsx(N,{variant:s.encryptedSecret?"success":"primary",children:s.encryptedSecret?"Secret Provided":"Pending Secret"})}),e.jsx(m,{children:e.jsx(N,{variant:"primary",children:e.jsx(b,{content:s.accessType===f.Anyone?"Anyone can input the secret.":"Only members of the organization can input the secret.",children:e.jsx("div",{children:s.accessType===f.Anyone?"Anyone":"Organization Members"})})})}),e.jsx(m,{children:`${q(new Date(s.createdAt),"yyyy-MM-dd - HH:mm a")}`}),e.jsx(m,{children:s.expiresAt?q(new Date(s.expiresAt),"yyyy-MM-dd - HH:mm a"):"-"}),e.jsx(m,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{content:s.encryptedSecret?"Reveal secret":"Secret value must be provided before it can be viewed.",children:e.jsx(S,{isDisabled:!s.encryptedSecret,className:s.encryptedSecret?"":"op
1acity-50",onClick:async i=>{i.stopPropagation();const a=await n({id:s.id});r("revealSecretRequestValue",{secretValue:a.secretValue,secretRequestName:a.name})},variant:"plain",ariaLabel:"reveal",children:e.jsx(j,{className:t?"animate-spin":"",icon:t?ie:ne})})}),e.jsx(b,{content:"Copy link",children:e.jsx(S,{isDisabled:!!s.encryptedSecret||c,className:s.encryptedSecret||c?"opacity-50":"",onClick:async i=>{i.stopPropagation(),navigator.clipboard.writeText(`${window.location.origin}/secret-request/secret/${s.id}`),y({text:"Shared secret link copied to clipboard.",type:"success"})},variant:"plain",ariaLabel:"copy link",children:e.jsx(j,{icon:V})})}),e.jsx(b,{content:"Delete",children:e.jsx(S,{onClick:i=>{i.stopPropagation(),r("deleteSecretRequestConfirmation",{name:"delete",id:s.id})},variant:"plain",ariaLabel:"delete",children:e.jsx(j,{icon:H})})})]})})]},s.id)},Oe=({handlePopUpOpen:s})=>{var p,h;const[r,n]=C.useState(1),[t,c]=C.useState(10),{isPending:i,data:a}=be({offset:(r-1)*t,limit:t});return e.jsxs($,{children:[e.jsxs(z,{children:[e.jsx(E,{children:e.jsxs(P,{children:[e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Status"}),e.jsx(u,{children:"Access Type"}),e.jsx(u,{children:"Created At"}),e.jsx(u,{children:"Valid Until"}),e.jsx(u,{"aria-label":"button",className:"w-5"})]})}),e.jsxs(L,{children:[i&&e.jsx(F,{columns:7,innerKey:"shared-secrets"}),!i&&((p=a==null?void 0:a.secrets)==null?void 0:p.map(l=>e.jsx(Re,{row:l,handlePopUpOpen:s},l.id)))]})]}),!i&&(a==null?void 0:a.secrets)&&(a==null?void 0:a.totalCount)>=t&&(a==null?void 0:a.totalCount)!==void 0&&e.jsx(Z,{count:a.totalCount,page:r,perPage:t,onChangePage:l=>n(l),onChangePerPage:l=>c(l)}),!i&&!((h=a==null?void 0:a.secrets)!=null&&h.length)&&e.jsx(Y,{title:"No secrets requested yet",icon:K})]})},Te=({secretValue:s,secretRequestName:r})=>{const[n,t]=le(!1);return e.jsxs(e.Fragment,{children:[r&&e.jsxs("p",{className:"mb-8 text-sm text-mineshaft-200",children:["Shared secret value for ",e.jsx("strong",{children:r})]}),e.jsxs("div",{className:"mb-8 flex items-center justify-between rounded-md bg-mineshaft-700 p-2 text-base text-gray-400",children:[e.jsx("p",{className:"mr-4 break-all",children:s}),e.jsx(b,{content:"Click to copy",children:e.jsx(S,{ariaLabel:"copy icon",colorSchema:"secondary",className:"group relative",onClick:()=>{navigator.clipboard.writeText(s),t.on()},children:e.jsx(j,{icon:n?D:V})})})]}),e.jsx("div",{className:"mt-8 flex w-full items-center justify-between gap-2",children:e.jsx(ce,{asChild:!0,children:e.jsx(w,{colorSchema:"secondary",children:"Close"})})})]})},Ve=({isOpen:s,onOpenChange:r,popUp:n})=>{const t=n.revealSecretRequestValue.data,c=t!=null&&t.secretRequestName?`Shared secret value for secret request ${t.secretRequestName}`:"Shared secret value";return e.jsx(I,{isOpen:s,onOpenChange:r,children:e.jsx(M,{title:c,children:e.jsx(Te,{secretRequestName:t==null?void 0:t.secretRequestName,secretValue:t==null?void 0:t.secretValue})})})},ke=()=>{var a,p,h,l;const{popUp:s,handlePopUpToggle:r,handlePopUpClose:n,handlePopUpOpen:t}=G(["createSecretRequest","deleteSecretRequestConfirmation","revealSecretRequestValue"]),{mutateAsync:c}=fe(),i=async()=>{var o;try{await c({secretRequestId:(o=s.deleteSecretRequestConfirmation.data)==null?void 0:o.id}),y({text:"Successfully deleted secret request",type:"success"}),n("deleteSecretRequestConfirmation")}catch(d){console.error(d),y({text:"Failed to delete shared secret",type:"error"})}};return e.jsxs("div",{className:"mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4",children:[e.jsxs("div",{className:"mb-4 flex justify-between",children:[e.jsx("p",{className:"text-xl font-semibold text-mineshaft-100",children:"Secret Requests"}),e.jsx(w,{colorSchema:"primary",leftIcon:e.jsx(j,{icon:_}),onClick:()=>{t("createSecretRequest")},children:"Request Secret"})]}),e.jsx(Oe,{handlePopUpOpen:t}),e.jsx(Pe,{popUp:s,handlePopUpToggle:r}),e.jsx(Ve,{isOpen:s.revealSecretRequestValue.isOpen,popUp:s,onOpenChange:o=>r("revealSecretRequestValue",o)}),e.jsx(B,{isOpen:s.deleteSecretRequestConfirmation.isOpen,title:`Delete ${((p=(a=s==null?void 0:s.deleteSecretRequestConfirmation)==null?void 0:a.data)==null?void 0:p.name)||" "} secret request?`,onChange:o=>r("deleteSecretRequestConfirmation",o),deleteKey:(l=(h=s==null?void 0:s.deleteSecretRequestConfirmation)==null?void 0:h.data)==null?void 0:l.name,onClose:()=>n("deleteSecretRequestConfirmation"),onDeleteApproved:i})]})},Ue=({row:s,handlePopUpOpen:r})=>{const n=s.lastViewedAt?q(new Date(s.lastViewedAt),"yyyy-MM-dd - HH:mm a"):void 0;let t=!1;return s.expiresAfterViews!==null&&s.expiresAfterViews<=0&&(t=!0),s.expiresAt!==null&&new Date(s.expiresAt)<new Date&&(t=!0),e.jsxs(P,{children:[e.jsx(m,{children:e.jsx(b,{content:n?`Last opened at ${n}`:"Not yet opened",children:e.jsx(j,{icon:n?oe:de})})}),e.jsx(m,{children:s.name?`${s.name}`:"-"}),e.jsx(m,{children:e.jsx(N,{variant:t?"danger":"success",children:t?"Expired":"Active"})}),e.jsx(m,{children:`${q(new Date(s.createdAt),"yyyy-MM-dd - HH:mm a")}`}
1),e.jsx(m,{children:q(new Date(s.expiresAt),"yyyy-MM-dd - HH:mm a")}),e.jsx(m,{children:s.expiresAfterViews!==null?s.expiresAfterViews:"-"}),e.jsx(m,{children:e.jsx(S,{onClick:c=>{c.stopPropagation(),r("deleteSharedSecretConfirmation",{name:"delete",id:s.id})},variant:"plain",ariaLabel:"delete",children:e.jsx(j,{icon:H})})})]},s.id)},De=({handlePopUpOpen:s})=>{var p,h;const[r,n]=C.useState(1),[t,c]=C.useState(10),{isPending:i,data:a}=ve({offset:(r-1)*t,limit:t});return e.jsxs($,{children:[e.jsxs(z,{children:[e.jsx(E,{children:e.jsxs(P,{children:[e.jsx(u,{className:"w-5"}),e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Status"}),e.jsx(u,{children:"Created At"}),e.jsx(u,{children:"Valid Until"}),e.jsx(u,{children:"Views Left"}),e.jsx(u,{"aria-label":"button",className:"w-5"})]})}),e.jsxs(L,{children:[i&&e.jsx(F,{columns:7,innerKey:"shared-secrets"}),!i&&((p=a==null?void 0:a.secrets)==null?void 0:p.map(l=>e.jsx(Ue,{row:l,handlePopUpOpen:s},l.id)))]})]}),!i&&(a==null?void 0:a.secrets)&&(a==null?void 0:a.totalCount)>=t&&(a==null?void 0:a.totalCount)!==void 0&&e.jsx(Z,{count:a.totalCount,page:r,perPage:t,onChangePage:l=>n(l),onChangePerPage:l=>c(l)}),!i&&!((h=a==null?void 0:a.secrets)!=null&&h.length)&&e.jsx(Y,{title:"No secrets shared yet",icon:K})]})},Ie=()=>{var a,p,h,l;const{popUp:s,handlePopUpToggle:r,handlePopUpClose:n,handlePopUpOpen:t}=G(["createSharedSecret","deleteSharedSecretConfirmation"]),c=Se(),i=async()=>{var o,d;try{c.mutateAsync({sharedSecretId:(d=(o=s==null?void 0:s.deleteSharedSecretConfirmation)==null?void 0:o.data)==null?void 0:d.id}),y({text:"Successfully deleted shared secret",type:"success"}),n("deleteSharedSecretConfirmation")}catch(x){console.error(x),y({text:"Failed to delete shared secret",type:"error"})}};return e.jsxs("div",{className:"mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4",children:[e.jsxs("div",{className:"mb-4 flex justify-between",children:[e.jsx("p",{className:"text-xl font-semibold text-mineshaft-100",children:"Shared Secrets"}),e.jsx(w,{colorSchema:"primary",leftIcon:e.jsx(j,{icon:_}),onClick:()=>{t("createSharedSecret")},children:"Share Secret"})]}),e.jsx(De,{handlePopUpOpen:t}),e.jsx(Ce,{popUp:s,handlePopUpToggle:r}),e.jsx(B,{isOpen:s.deleteSharedSecretConfirmation.isOpen,title:`Delete ${((p=(a=s==null?void 0:s.deleteSharedSecretConfirmation)==null?void 0:a.data)==null?void 0:p.name)||" "} shared secret?`,onChange:o=>r("deleteSharedSecretConfirmation",o),deleteKey:(l=(h=s==null?void 0:s.deleteSharedSecretConfirmation)==null?void 0:h.data)==null?void 0:l.name,onClose:()=>n("deleteSharedSecretConfirmation"),onDeleteApproved:i})]})},Me=()=>{const s=he(),{selectedTab:r}=pe({from:Q.Organization.SecretSharing.id}),n=t=>{s({to:Q.Organization.SecretSharing.path,search:c=>({...c,selectedTab:t})})};return e.jsxs("div",{children:[e.jsxs(X,{children:[e.jsx("title",{children:"Secret Sharing"}),e.jsx("link",{rel:"icon",href:"/infisical.ico"}),e.jsx("meta",{property:"og:image",content:"/images/message.png"})]}),e.jsxs(ue,{value:r,onValueChange:n,children:[e.jsxs(je,{children:[e.jsx(J,{value:"share-secret",children:"Share Secrets"}),e.jsxs(J,{value:"request-secret",children:["Request Secrets",e.jsx(N,{variant:"primary",className:"ml-1 cursor-pointer text-xs",children:"New"})]})]}),e.jsx(W,{value:"share-secret",children:e.jsx(Ie,{})}),e.jsx(W,{value:"request-secret",children:e.jsx(ke,{})})]})]})},He=()=>{const{t:s}=we();return e.jsxs(e.Fragment,{children:[e.jsxs(X,{children:[e.jsx("title",{children:s("common.head-title",{title:s("approval.title")})}),e.jsx("link",{rel:"icon",href:"/infisical.ico"}),e.jsx("meta",{property:"og:image",content:"/images/message.png"}),e.jsx("meta",{property:"og:title",content:String(s("approval.og-title"))}),e.jsx("meta",{name:"og:description",content:String(s("approval.og-description"))})]}),e.jsx("div",{className:"h-full",children:e.jsxs("div",{className:"container mx-auto h-full w-full max-w-7xl bg-bunker-800 text-white",children:[e.jsx(me,{title:"Secret Sharing",description:"Share secrets securely using a shareable link",children:e.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:"https://infisical.com/docs/documentation/platform/secret-sharing",children:e.jsxs("div",{className:"flex w-max cursor-pointer items-center rounded-md border border-mineshaft-500 bg-mineshaft-600 px-4 py-2 text-mineshaft-200 duration-200 hover:border-primary/40 hover:bg-primary/10 hover:text-white",children:["Documentation"," ",e.jsx(j,{icon:xe,className:"mb-[0.06rem] ml-1 text-xs"})]})})}),e.jsx(Me,{})]})})]})},$e=He;export{$e as component};
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.