1import{r as s,j as e}from"./index-BRXndiYS.js";import{g as z,c as B,v as L,s as W,r as F,K as S,a as N,V as Y,b as $}from"./platformKmsConfig-CGCAo-3o.js";/* empty css */function X(){const[r,a]=s.useState("status"),[h,l]=s.useState(!1),[m,t]=s.useState(null),[f,i]=s.useState(null),[o,p]=s.useState(null),[x,K]=s.useState(""),[b,M]=s.useState(""),[j,R]=s.useState(""),[A,k]=s.useState(!1),[T,_]=s.useState(!1),[v,O]=s.useState("platform_byok"),[g,w]=s.useState(""),[V,C]=s.useState(!1),u=s.useCallback(async()=>{var c,d;l(!0),t(null);try{const n=await z();p(n)}catch(n){t(((d=(c=n.response)==null?void 0:c.data)==null?void 0:d.detail)||"Failed to load KMS configuration")}finally{l(!1)}},[]);s.useEffect(()=>{u()},[u]);const P=s.useCallback(async()=>{var c,d;if(!x.trim()){t("KMS Key ARN is required");return}k(!0),t(null),i(null);try{await B({platform_kms_key_arn:x.trim(),platform_kms_role_arn:b.trim()||null,platform_kms_external_id:j.trim()||null}),i("KMS configured. Please verify access."),await u(),a("status")}catch(n){t(((d=(c=n.response)==null?void 0:c.data)==null?void 0:d.detail)||"Failed to configure KMS")}finally{k(!1)}},[x,b,j,u]),E=s.useCallback(async()=>{var c,d;_(!0),t(null),i(null);try{const n=await L();n.success?i("KMS verification successful!"):t(`Verification failed: ${n.error_message||"Unknown error"}`),await u()}catch(n){t(((d=(c=n.response)==null?void 0:c.data)==null?void 0:d.detail)||"Verification failed")}finally{_(!1)}},[u]),I=s.useCallback(async()=>{var c,d;if(g!=="platform"){t("Type 'platform' to confirm mode switch");return}C(!0),t(null),i(null);try{const n=await W({target_mode:v,confirmation_text:g});i(n.message),w(""),await u(),a("status")}catch(n){t(((d=(c=n.response)==null?void 0:c.data)==null?void 0:d.detail)||"Mode switch failed")}finally{C(!1)}},[v,g,u]),D=s.useCallback(async()=>{var c,d;if(confirm("Are you sure you want to reset KMS config to Specora-managed mode?")){l(!0),t(null),i(null);try{await F(),i("KMS config reset to Specora-managed mode"),await u()}catch(n){t(((d=(c=n.response)==null?void 0:c.data)==null?void 0:d.detail)||"Reset failed")}finally{l(!1)}}},[u]);return e.jsxs("div",{className:"ai-safety-page",children:[e.jsxs("div",{className:"ai-safety-header",children:[e.jsx("h1",{children:"Platform KMS Configuration"}),e.jsx("p",{className:"subtitle",children:"Configure AWS KMS for encrypting platform-level provider credentials"})]}),m&&e.jsxs("div",{className:"error-banner",children:[e.jsx("span",{children:m}),e.jsx("button",{onClick:()=>t(null),children:"Ã"})]}),f&&e.jsxs("div",{className:"error-banner",style:{background:"var(--color-success-bg)",color:"var(--color-success)"},children:[e.jsx("span",{children:f}),e.jsx("button",{onClick:()=>i(null),children:"Ã"})]}),e.jsxs("div",{className:"ai-safety-tabs",children:[e.jsx("button",{className:r==="status"?"active":"",onClick:()=>a("status"),children:"Status"}),e.jsx("button",{className:r==="configure"?"active":"",onClick:()=>a("configure"),children:"Configure"}),e.jsx("button",{className:r==="mode"?"active":"",onClick:()=>a("mode"),children:"Mode Switch"})]}),h&&!o&&e.jsx("div",{className:"loading-spinner",children:"Loading..."}),r==="status"&&o&&e.jsx(q,{config:o,onVerify:E,onReset:D,verifying:T,loading:h}),r==="configure"&&e.jsx(U,{keyArn:x,setKeyArn:K,roleArn:b,setRoleArn:M,externalId:j,setExternalId:R,onConfigure:P,configuring:A}),r==="mode"&&o&&e.jsx(G,{currentMode:o.kms_mode,targetMode:v,setTargetMode:O,confirmationText:g,setConfirmationText:w,onSwitch:I,switching:V,verificationStatus:o.verification_status})]})}function q({config:r,onVerify:a,onReset:h,verifying:l,loading:m}){return e.jsxs("div",{className:"agent-status",children:[e.jsxs("div",{className:"agent-status-header",children:[e.jsx("h2",{children:"Current Configuration"}),e.jsx("span",{className:`badge ${N(r.kms_mode)}`,children:S[r.kms_mode]})]}),e.jsxs("div",{className:"config-display",style:{marginTop:"1rem"},children:[e.jsxs("div",{className:"config-item",children:[e.jsx("label",{children:"KMS Mode"}),e.jsx("span",{children:S[r.kms_mode]})]}),e.jsxs("div",{className:"config-item",children:[e.jsx("label",{children:"Verification Status"}),e.jsx("span",{className:`badge ${$(r.verification_status)}`,children:Y[r.verification_status]})]}),r.platform_kms_key_arn&&e.jsxs("div",{className:"config-item",children:[e.jsx("label",{children:"KMS Key ARN (Masked)"}),e.jsx("code",{style:{fontSize:"0.85rem"},children:r.platform_kms_key_arn})]}),r.platform_kms_role_arn&&e.jsxs("div",{className:"config-item",children:[e.jsx("label",{children:"IAM Role ARN (Masked)"}),e.jsx("code",{style:{fontSize:"0.85rem"},children:r.platform_kms_role_arn})]}),r.verification_error&&e.jsxs("div",{className:"config-item",children:[e.jsx("label",{children:"Verification
1Error"}),e.jsx("span",{style:{color:"var(--color-error)"},children:r.verification_error})]}),r.last_verified_at&&e.jsxs("div",{className:"config-item",children:[e.jsx("label",{children:"Last Verified"}),e.jsx("span",{children:new Date(r.last_verified_at).toLocaleString()})]}),r.configured_at&&e.jsxs("div",{className:"config-item",children:[e.jsx("label",{children:"Configured At"}),e.jsx("span",{children:new Date(r.configured_at).toLocaleString()})]}),r.mode_switched_at&&e.jsxs("div",{className:"config-item",children:[e.jsx("label",{children:"Mode Switched At"}),e.jsx("span",{children:new Date(r.mode_switched_at).toLocaleString()})]})]}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",gap:"0.75rem"},children:[r.platform_kms_key_arn&&e.jsx("button",{onClick:a,disabled:l,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"none",background:"var(--color-primary)",color:"white",cursor:l?"not-allowed":"pointer",opacity:l?.6:1},children:l?"Verifying...":"Verify KMS Access"}),r.kms_mode==="platform_byok"&&e.jsx("button",{onClick:h,disabled:m,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"1px solid var(--color-error)",background:"transparent",color:"var(--color-error)",cursor:m?"not-allowed":"pointer",opacity:m?.6:1},children:"Reset to Specora Mode"})]})]})}function U({keyArn:r,setKeyArn:a,roleArn:h,setRoleArn:l,externalId:m,setExternalId:t,onConfigure:f,configuring:i}){return e.jsxs("div",{className:"agent-status",children:[e.jsx("div",{className:"agent-status-header",children:e.jsx("h2",{children:"Configure KMS"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsxs("label",{style:{display:"block",marginBottom:"0.25rem",fontWeight:500},children:["KMS Key ARN ",e.jsx("span",{style:{color:"var(--color-error)"},children:"*"})]}),e.jsx("input",{type:"text",value:r,onChange:o=>a(o.target.value),placeholder:"arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012",style:{width:"100%",padding:"0.5rem",borderRadius:"0.375rem",border:"1px solid var(--color-border)",background:"var(--color-bg-secondary)",color:"var(--color-text-primary)",fontSize:"0.875rem",fontFamily:"monospace"}}),e.jsx("small",{style:{color:"var(--color-text-secondary)"},children:"AWS KMS key ARN for encrypting provider credentials"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:"0.25rem",fontWeight:500},children:"IAM Role ARN (Optional)"}),e.jsx("input",{type:"text",value:h,onChange:o=>l(o.target.value),placeholder:"arn:aws:iam::123456789012:role/SpecoraKmsRole",style:{width:"100%",padding:"0.5rem",borderRadius:"0.375rem",border:"1px solid var(--color-border)",background:"var(--color-bg-secondary)",color:"var(--color-text-primary)",fontSize:"0.875rem",fontFamily:"monospace"}}),e.jsx("small",{style:{color:"var(--color-text-secondary)"},children:"For cross-account KMS access via STS AssumeRole"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:"0.25rem",fontWeight:500},children:"External ID (Optional)"}),e.jsx("input",{type:"text",value:m,onChange:o=>t(o.target.value),placeholder:"specora-platform-kms-external-id",style:{width:"100%",padding:"0.5rem",borderRadius:"0.375rem",border:"1px solid var(--color-border)",background:"var(--color-bg-secondary)",color:"var(--color-text-primary)",fontSize:"0.875rem"}}),e.jsx("small",{style:{color:"var(--color-text-secondary)"},children:"External ID for STS AssumeRole (recommended for security)"})]}),e.jsx("button",{onClick:f,disabled:i||!r.trim(),style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"none",background:"var(--color-primary)",color:"white",cursor:i||!r.trim()?"not-allowed":"pointer",opacity:i||!r.trim()?.6:1,alignSelf:"flex-start",marginTop:"0.5rem"},children:i?"Configuring...":"Save Configuration"})]})]})}function G({currentMode:r,targetMode:a,setTargetMode:h,confirmationText:l,setConfirmationText:m,onSwitch:t,switching:f,verificationStatus:i}){const o=i==="verified";return e.jsxs("div",{className:"agent-status",children:[e.jsx("div",{className:"agent-status-header",children:e.jsx("h2",{children:"Switch KMS Mode"})}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsxs("div",{className:"config-item",children:[e.jsx("label",{children:"Current Mode"}),e.jsx("span",{className:`badge ${N(r)}`,children:S[r]})]})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1.5rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:"0.25rem",fontWeight:500},children:"Target Mode"}),e.jsxs("select",{value:a,onChange:p=>h(p.target.value),style:{width:"100%",padding:"0.5rem",borderRadius:"0.375rem",border:"1px solid var(--color-border)",background:"var(--color-bg-secondary)",color:"var(--color-text-primary)",fontSize:"0.875rem"},children:[e.jsx("option",{value:"specora",children:"Specora-Managed"}),e.jsxs("option",{value:"platform_byok",disabled:!o,children:["Platform BYOK ",!o&&"(requires verification)"]})]})]}),a!==r&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"1rem",background:"var(--color-warning-bg)",borderRadius:"0.375rem",border:"1px solid var(--color-warning)"},children:[e.jsx("strong",{style:{color:"var(--color-warning)"},children:"Warning:"}),e.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.875rem"},children:a==="platform_byok"?"Switching to Platform BYOK will encrypt all new provider credentials with your KMS key.":"Switching to Specora-managed will use Specora-managed encryption for new credentials."})]}),e.jsxs("div",{children:[e.jsxs("label",{style:{display:"block",marginBottom:"0.25rem",fontWeight:500},children:["Type ",e.jsx("code",{children:"platform"})," to confirm"]}
1),e.jsx("input",{type:"text",value:l,onChange:p=>m(p.target.value),placeholder:"platform",style:{width:"100%",padding:"0.5rem",borderRadius:"0.375rem",border:"1px solid var(--color-border)",background:"var(--color-bg-secondary)",color:"var(--color-text-primary)",fontSize:"0.875rem"}})]}),e.jsx("button",{onClick:t,disabled:f||l!=="platform"||a===r||a==="platform_byok"&&!o,style:{padding:"0.5rem 1rem",borderRadius:"0.375rem",border:"none",background:"var(--color-warning)",color:"white",cursor:f||l!=="platform"||a===r||a==="platform_byok"&&!o?"not-allowed":"pointer",opacity:f||l!=="platform"||a===r||a==="platform_byok"&&!o?.6:1,alignSelf:"flex-start"},children:f?"Switching...":"Switch Mode"})]})]})]})}export{X 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.