@coffre/ui 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/client/_coffre/assets/{account-aO-xPRzC.js → account-C3rBPdu6.js} +2 -2
  2. package/dist/client/_coffre/assets/{account-BIyXNVE7.js → account-J194gi6l.js} +1 -1
  3. package/dist/client/_coffre/assets/{audit-SvZcBu5r.js → audit-CdCJ1U8E.js} +2 -2
  4. package/dist/client/_coffre/assets/{audit-BOhJ99zA.js → audit-EWPPhR7U.js} +1 -1
  5. package/dist/client/_coffre/assets/{auth.device-DKOf08ug.js → auth.device--rDR2F8w.js} +1 -1
  6. package/dist/client/_coffre/assets/{auth.device-u__CNnL_.js → auth.device-viDUwZRT.js} +2 -2
  7. package/dist/client/_coffre/assets/{coffre-B0SRYkyG.js → coffre-CXkp3Efg.js} +1 -1
  8. package/dist/client/_coffre/assets/{directory--9Q70fmm.js → directory-PEjdb8PS.js} +1 -1
  9. package/dist/client/_coffre/assets/globals-Bh2x1gBM.css +1 -0
  10. package/dist/client/_coffre/assets/{grants-BxXkQT0q.js → grants-4mSkXPU4.js} +1 -1
  11. package/dist/client/_coffre/assets/index-DoJkcH-T.js +12 -0
  12. package/dist/client/_coffre/assets/{offboarding-BmFuQEv1.js → offboarding-DQ-56W0H.js} +1 -1
  13. package/dist/client/_coffre/assets/{principal-page-CaAlOB_1.js → principal-page-DjH1cUyz.js} +1 -1
  14. package/dist/client/_coffre/assets/{projects._project._environment-D5vWbgMo.js → projects._project._environment-BZnNvENc.js} +1 -1
  15. package/dist/client/_coffre/assets/{projects._project._environment-CAHNmhje.js → projects._project._environment-CLUpTvi-.js} +2 -2
  16. package/dist/client/_coffre/assets/{projects._project.index-CnqMmMG7.js → projects._project.index-CWXRo307.js} +2 -2
  17. package/dist/client/_coffre/assets/{projects._project.index-BQw4N8k-.js → projects._project.index-Dzgf95zv.js} +1 -1
  18. package/dist/client/_coffre/assets/{projects.index-DHIeFVLP.js → projects.index-BG8W91BX.js} +2 -2
  19. package/dist/client/_coffre/assets/{projects.index-9RVSbXjb.js → projects.index-N_kCFBMq.js} +1 -1
  20. package/dist/client/_coffre/assets/{settings-DYc9gBwr.js → settings-CNIY0--5.js} +1 -1
  21. package/dist/client/_coffre/assets/{settings-BHtK75j4.js → settings-EimGqlQL.js} +2 -2
  22. package/dist/client/_coffre/assets/{tokens._token-Yb0ESFen.js → tokens._token-CkU4dCwo.js} +1 -1
  23. package/dist/client/_coffre/assets/tokens._token-Df2R8TF_.js +2 -0
  24. package/dist/client/_coffre/assets/tokens.index-CSf5Mlz8.js +2 -0
  25. package/dist/client/_coffre/assets/{tokens.index-Cl6jAaG1.js → tokens.index-DtiWrKVq.js} +1 -1
  26. package/dist/client/_coffre/assets/{use-action-LiHC8kKH.js → use-action-CUvWPRTx.js} +1 -1
  27. package/dist/client/_coffre/assets/{users._user-Dd--epXf.js → users._user-CImGVpYj.js} +1 -1
  28. package/dist/client/_coffre/assets/users._user-D0JK911L.js +2 -0
  29. package/dist/client/_coffre/assets/{users.index-CBnyTZ5s.js → users.index-B-7o0KBD.js} +1 -1
  30. package/dist/client/_coffre/assets/users.index-BoFWF3mF.js +2 -0
  31. package/dist/server/.vite/manifest.json +171 -171
  32. package/dist/server/_coffre/assets/{_tanstack-start-manifest_v-DxrPXbxf.js → _tanstack-start-manifest_v-C2PEUeJL.js} +33 -33
  33. package/dist/server/_coffre/assets/{account-BCWiHL02.js → account-CZgVVZTf.js} +7 -7
  34. package/dist/server/_coffre/assets/{account-o6Aa9ewL.js → account-D7-ZAE2T.js} +5 -5
  35. package/dist/server/_coffre/assets/{audit-LnICjwY-.js → audit-Bb9Er3nm.js} +3 -3
  36. package/dist/server/_coffre/assets/{audit-DErFBScb.js → audit-CnfDYD-u.js} +3 -3
  37. package/dist/server/_coffre/assets/{auth.device-SSruoUMA.js → auth.device-CMR3csAI.js} +3 -3
  38. package/dist/server/_coffre/assets/{auth.device-MPFjFR1J.js → auth.device-w9N3FlNk.js} +4 -4
  39. package/dist/server/_coffre/assets/{coffre-1hxT2E_U.js → coffre-DMs96kfX.js} +3 -1
  40. package/dist/server/_coffre/assets/{directory-CRoVBkX-.js → directory-Dr5X9TB5.js} +4 -4
  41. package/dist/server/_coffre/assets/globals-Bh2x1gBM.css +1 -0
  42. package/dist/server/_coffre/assets/{grants-ahmQsPAJ.js → grants-C6UmWE8b.js} +4 -4
  43. package/dist/server/_coffre/assets/{login-SfzjEmZT.js → login-B2njIq_o.js} +2 -2
  44. package/dist/server/_coffre/assets/{login-CQw_o6Gr.js → login-DUtCQju5.js} +3 -3
  45. package/dist/server/_coffre/assets/{offboarding-uVHZUfo4.js → offboarding-DY5MarpG.js} +3 -3
  46. package/dist/server/_coffre/assets/{page-DiOsIrE3.js → page-BdnhpwvH.js} +1 -1
  47. package/dist/server/_coffre/assets/{principal-page-DtNYUrPB.js → principal-page-SdG8_zcu.js} +7 -7
  48. package/dist/server/_coffre/assets/{projects._project._environment-DX0oRk5K.js → projects._project._environment-BQIrmE3r.js} +3 -3
  49. package/dist/server/_coffre/assets/{projects._project._environment-B32fcj4E.js → projects._project._environment-CUS0VFUe.js} +5 -5
  50. package/dist/server/_coffre/assets/{projects._project.index-DolB6jZJ.js → projects._project.index-BjNdR4KC.js} +3 -3
  51. package/dist/server/_coffre/assets/{projects._project.index-CVXek833.js → projects._project.index-D1NxvBtZ.js} +7 -7
  52. package/dist/server/_coffre/assets/{projects.index-JE5sEeRy.js → projects.index-BQDuuh6t.js} +5 -5
  53. package/dist/server/_coffre/assets/{projects.index-DRUvHYRZ.js → projects.index-ha7jO4nC.js} +3 -3
  54. package/dist/server/_coffre/assets/{router-C8HpE1F2.js → router-BimLwejs.js} +32 -85
  55. package/dist/server/_coffre/assets/{settings-RcERS7mp.js → settings-Cy__khNA.js} +4 -4
  56. package/dist/server/_coffre/assets/{settings-BI5qwClp.js → settings-HOErM3pd.js} +4 -4
  57. package/dist/server/_coffre/assets/{tokens._token-DAWPmrdO.js → tokens._token-BZUArbzi.js} +6 -6
  58. package/dist/server/_coffre/assets/{tokens._token-BuCKWsUv.js → tokens._token-CmpmtfB_.js} +4 -4
  59. package/dist/server/_coffre/assets/{tokens.index-BLOTM9hK.js → tokens.index-B5-4dD4C.js} +3 -3
  60. package/dist/server/_coffre/assets/{tokens.index-C31-24r3.js → tokens.index-BReCgoV9.js} +4 -4
  61. package/dist/server/_coffre/assets/{ui-LHVjaG5-.js → ui-D_slKpSF.js} +1 -1
  62. package/dist/server/_coffre/assets/{unregistered-DRza-1nD.js → unregistered-Z17da4Rc.js} +1 -1
  63. package/dist/server/_coffre/assets/{use-action-BkJXC5JM.js → use-action-DQUmeH-5.js} +1 -1
  64. package/dist/server/_coffre/assets/{users._user-CC9cDYJq.js → users._user-BKdSQhIg.js} +3 -3
  65. package/dist/server/_coffre/assets/{users._user-CTNj1X5H.js → users._user-DHTNhQ9o.js} +2 -2
  66. package/dist/server/_coffre/assets/{users.index-CNR62ijQ.js → users.index-Cfo3ODpX.js} +4 -4
  67. package/dist/server/_coffre/assets/{users.index-CwDEKMnN.js → users.index-dMn0tlmc.js} +3 -3
  68. package/dist/server/index.js +2 -2
  69. package/package.json +3 -3
  70. package/src/components/command-palette.tsx +1 -1
  71. package/src/components/icons.tsx +1 -1
  72. package/src/components/shell.tsx +8 -56
  73. package/src/routes/account.tsx +1 -1
  74. package/src/routes/settings.tsx +1 -1
  75. package/src/styles/globals.css +30 -36
  76. package/dist/client/_coffre/assets/globals-BvlyrLi8.css +0 -1
  77. package/dist/client/_coffre/assets/index-CBgc7lsY.js +0 -12
  78. package/dist/client/_coffre/assets/tokens._token-D69aJAyr.js +0 -2
  79. package/dist/client/_coffre/assets/tokens.index-T5bax16J.js +0 -2
  80. package/dist/client/_coffre/assets/users._user-5op2n3T0.js +0 -2
  81. package/dist/client/_coffre/assets/users.index-D2wC7VUt.js +0 -2
  82. package/dist/server/_coffre/assets/globals-BvlyrLi8.css +0 -1
@@ -1 +1 @@
1
- import{C as e,X as t,ct as n,f as r,q as i,t as a}from"./page-DbSS7pYH.js";import{D as o,a as s,c,u as l}from"./preload-helper-DduCCcmc.js";import{c as u}from"./directory--9Q70fmm.js";var d=n();function f({report:e}){let t=e.status===`removed`,n=e.principalType===`user`;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(h,{report:e,removed:t,person:n}),e.syncs.length>0&&(0,d.jsx)(g,{report:e,person:n}),e.issuedTokens.length>0&&(0,d.jsx)(_,{report:e})]})}function p({report:e}){let t=e.principalType===`user`;return(0,d.jsx)(`div`,{className:`report-notice`,children:(0,d.jsxs)(c,{children:[`Removed`,e.removedBy!==null&&(0,d.jsxs)(d.Fragment,{children:[` `,`by `,(0,d.jsx)(`span`,{className:`mono`,children:e.removedBy})]}),e.removedAt!==null&&(0,d.jsxs)(d.Fragment,{children:[` `,`on `,(0,d.jsx)(l,{iso:e.removedAt})]}),`.`,` `,t?`Their project access, sessions, CLI logins and linked sign-in accounts were revoked at the same time, so adding them again starts from nothing.`:`Its project access and every token issued to it were revoked at the same time, so adding it again starts from nothing.`]})})}function m({principalType:n,removed:i}){let a=n===`user`,o=i.filter(e=>e.principalType===n);return o.length===0?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`h2`,{className:`section-title`,children:`Removed`}),(0,d.jsx)(`section`,{className:`card`,"aria-label":a?`Removed users`:`Removed tokens`,children:(0,d.jsx)(`div`,{className:`dt-wrap`,children:(0,d.jsxs)(`table`,{className:`dt directory stacks`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{className:`n`,children:`#`}),(0,d.jsx)(`th`,{className:`col-principal`,children:(0,d.jsxs)(`span`,{className:`th`,children:[a?(0,d.jsx)(t,{size:14}):(0,d.jsx)(e,{size:14}),a?`Email`:`Name`]})}),(0,d.jsx)(`th`,{className:`col-role`,children:`Still to rotate`}),(0,d.jsx)(`th`,{className:`col-actions`,children:(0,d.jsx)(`span`,{className:`visually-hidden`,children:`Report`})})]})}),(0,d.jsx)(`tbody`,{children:o.map((e,t)=>(0,d.jsxs)(`tr`,{className:`row-link`,children:[(0,d.jsx)(`td`,{className:`n`,children:t+1}),(0,d.jsx)(`td`,{className:`col-lead`,"data-label":a?`Email`:`Name`,children:(0,d.jsx)(u,{type:e.principalType,id:e.principalId,stretch:!0})}),(0,d.jsx)(`td`,{className:`col-role`,"data-label":`Still to rotate`,children:e.toRotate===0?(0,d.jsx)(`span`,{className:`cell-muted`,children:`Nothing`}):`${e.toRotate} ${e.toRotate===1?`value`:`values`}`}),(0,d.jsx)(`td`,{className:`col-actions col-open cell-muted`,"aria-hidden":`true`,children:(0,d.jsx)(r,{size:16})})]},e.principalId))})]})})}),(0,d.jsxs)(`p`,{className:`hint section-foot`,children:[a?`They`:`These`,` can no longer sign in. Each page lists the values`,` `,a?`they`:`it`,` saw that nobody has changed since.`]})]})}function h({report:e,removed:t,person:n}){let r=n?`they`:`it`,i=t?`Values ${r} read or wrote that nobody has changed since, so ${r} may still hold them. Rotate each where it comes from, such as a new API key or database password, then save the new value here and it leaves this list.`:`Current values ${r} ${n?`have`:`has`} read or written: the ones to rotate if ${r} ${n?`leave`:`is retired`}. Saving a new version takes a value off.`;return(0,d.jsx)(a,{labelledBy:`seen-values`,title:t?`Still to rotate`:`Values seen`,description:i,actions:e.rotated>0&&(0,d.jsxs)(`span`,{className:`card-aside`,children:[e.rotated,` already rotated`]}),children:e.exposed.length===0?(0,d.jsx)(s,{title:t?`Nothing left to rotate`:`No current values seen`,children:e.rotated>0?`Every value ${r} saw has had a new version since.`:`${n?`They have`:`It has`} not read or written a value that is still current.`}):(0,d.jsx)(`div`,{className:`dt-wrap`,children:(0,d.jsxs)(`table`,{className:`dt report-values`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Secret`}),(0,d.jsx)(`th`,{className:`col-shrink`,children:`Version`}),(0,d.jsx)(`th`,{className:`col-shrink`,children:`Last seen`})]})}),(0,d.jsx)(`tbody`,{children:e.exposed.map(e=>(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`td`,{children:(0,d.jsxs)(o,{className:`cell-link mono`,to:`/projects/$project/$environment`,params:{project:e.project,environment:e.environment},search:{filter:e.key},children:[(0,d.jsxs)(`span`,{className:`report-path`,children:[e.project,`/`,e.environment,`/`]}),e.key]})}),(0,d.jsxs)(`td`,{className:`col-shrink cell-mono cell-muted`,children:[`v`,e.version]}),(0,d.jsxs)(`td`,{className:`col-shrink nowrap`,children:[e.how===`wrote`?`Wrote`:`Read`,` `,(0,d.jsx)(l,{iso:e.at,display:`relative`})]})]},`${e.project}/${e.environment}/${e.key}`))})]})})})}function g({report:e,person:t}){return(0,d.jsx)(a,{labelledBy:`created-syncs`,title:t?`Syncs they set up`:`Syncs it set up`,description:`A sync keeps pushing every change to the destination it names, whoever set it up. Check each one still points somewhere you control.`,children:(0,d.jsx)(`div`,{className:`dt-wrap`,children:(0,d.jsxs)(`table`,{className:`dt syncs`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Destination`}),(0,d.jsx)(`th`,{className:`col-shrink`,children:`From`}),(0,d.jsx)(`th`,{className:`col-shrink col-hide-narrow`,children:`Token`})]})}),(0,d.jsx)(`tbody`,{children:e.syncs.map(e=>(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`td`,{children:(0,d.jsxs)(`span`,{className:`cell-account`,children:[(0,d.jsx)(i,{brand:e.brand,size:15}),(0,d.jsxs)(`span`,{className:`cell-stack`,children:[(0,d.jsxs)(`span`,{children:[e.providerLabel,e.paused&&(0,d.jsx)(`span`,{className:`tag`,children:`Paused`})]}),(0,d.jsx)(`small`,{className:`mono`,children:e.destination})]})]})}),(0,d.jsx)(`td`,{className:`col-shrink`,children:(0,d.jsxs)(o,{className:`cell-link mono`,to:`/projects/$project/$environment`,params:{project:e.project,environment:e.environment},children:[e.project,`/`,e.environment]})}),(0,d.jsx)(`td`,{className:`col-shrink col-hide-narrow cell-mono cell-muted`,children:e.credential})]},e.id))})]})})})}function _({report:e}){return(0,d.jsx)(a,{labelledBy:`issued-tokens`,title:`Tokens they issued`,description:`Service tokens they created that still work. Each was shown to them once, when it was made; revoke any they may have kept a copy of.`,children:(0,d.jsx)(`div`,{className:`dt-wrap`,children:(0,d.jsxs)(`table`,{className:`dt report-tokens`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Token`}),(0,d.jsx)(`th`,{className:`col-shrink`,children:`Expires`}),(0,d.jsx)(`th`,{className:`col-shrink col-hide-narrow`,children:`Last used`})]})}),(0,d.jsx)(`tbody`,{children:e.issuedTokens.map(e=>(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`td`,{children:(0,d.jsxs)(`span`,{className:`cell-stack`,children:[(0,d.jsx)(o,{className:`cell-link mono`,to:`/tokens/$token`,params:{token:e.service},children:e.service}),(0,d.jsxs)(`small`,{children:[e.label??`No label`,` · `,(0,d.jsx)(`span`,{className:`mono`,children:e.hint})]})]})}),(0,d.jsx)(`td`,{className:`col-shrink nowrap`,children:(0,d.jsx)(l,{iso:e.expiresAt,display:`relative`})}),(0,d.jsx)(`td`,{className:`col-shrink col-hide-narrow nowrap`,children:e.lastUsedAt===null?(0,d.jsx)(`span`,{className:`cell-muted`,children:`Never`}):(0,d.jsx)(l,{iso:e.lastUsedAt,display:`relative`})})]},e.id))})]})})})}export{m as n,p as r,f as t};
1
+ import{C as e,X as t,ct as n,f as r,q as i,t as a}from"./page-DbSS7pYH.js";import{D as o,a as s,c,u as l}from"./preload-helper-DduCCcmc.js";import{c as u}from"./directory-PEjdb8PS.js";var d=n();function f({report:e}){let t=e.status===`removed`,n=e.principalType===`user`;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(h,{report:e,removed:t,person:n}),e.syncs.length>0&&(0,d.jsx)(g,{report:e,person:n}),e.issuedTokens.length>0&&(0,d.jsx)(_,{report:e})]})}function p({report:e}){let t=e.principalType===`user`;return(0,d.jsx)(`div`,{className:`report-notice`,children:(0,d.jsxs)(c,{children:[`Removed`,e.removedBy!==null&&(0,d.jsxs)(d.Fragment,{children:[` `,`by `,(0,d.jsx)(`span`,{className:`mono`,children:e.removedBy})]}),e.removedAt!==null&&(0,d.jsxs)(d.Fragment,{children:[` `,`on `,(0,d.jsx)(l,{iso:e.removedAt})]}),`.`,` `,t?`Their project access, sessions, CLI logins and linked sign-in accounts were revoked at the same time, so adding them again starts from nothing.`:`Its project access and every token issued to it were revoked at the same time, so adding it again starts from nothing.`]})})}function m({principalType:n,removed:i}){let a=n===`user`,o=i.filter(e=>e.principalType===n);return o.length===0?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`h2`,{className:`section-title`,children:`Removed`}),(0,d.jsx)(`section`,{className:`card`,"aria-label":a?`Removed users`:`Removed tokens`,children:(0,d.jsx)(`div`,{className:`dt-wrap`,children:(0,d.jsxs)(`table`,{className:`dt directory stacks`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{className:`n`,children:`#`}),(0,d.jsx)(`th`,{className:`col-principal`,children:(0,d.jsxs)(`span`,{className:`th`,children:[a?(0,d.jsx)(t,{size:14}):(0,d.jsx)(e,{size:14}),a?`Email`:`Name`]})}),(0,d.jsx)(`th`,{className:`col-role`,children:`Still to rotate`}),(0,d.jsx)(`th`,{className:`col-actions`,children:(0,d.jsx)(`span`,{className:`visually-hidden`,children:`Report`})})]})}),(0,d.jsx)(`tbody`,{children:o.map((e,t)=>(0,d.jsxs)(`tr`,{className:`row-link`,children:[(0,d.jsx)(`td`,{className:`n`,children:t+1}),(0,d.jsx)(`td`,{className:`col-lead`,"data-label":a?`Email`:`Name`,children:(0,d.jsx)(u,{type:e.principalType,id:e.principalId,stretch:!0})}),(0,d.jsx)(`td`,{className:`col-role`,"data-label":`Still to rotate`,children:e.toRotate===0?(0,d.jsx)(`span`,{className:`cell-muted`,children:`Nothing`}):`${e.toRotate} ${e.toRotate===1?`value`:`values`}`}),(0,d.jsx)(`td`,{className:`col-actions col-open cell-muted`,"aria-hidden":`true`,children:(0,d.jsx)(r,{size:16})})]},e.principalId))})]})})}),(0,d.jsxs)(`p`,{className:`hint section-foot`,children:[a?`They`:`These`,` can no longer sign in. Each page lists the values`,` `,a?`they`:`it`,` saw that nobody has changed since.`]})]})}function h({report:e,removed:t,person:n}){let r=n?`they`:`it`,i=t?`Values ${r} read or wrote that nobody has changed since, so ${r} may still hold them. Rotate each where it comes from, such as a new API key or database password, then save the new value here and it leaves this list.`:`Current values ${r} ${n?`have`:`has`} read or written: the ones to rotate if ${r} ${n?`leave`:`is retired`}. Saving a new version takes a value off.`;return(0,d.jsx)(a,{labelledBy:`seen-values`,title:t?`Still to rotate`:`Values seen`,description:i,actions:e.rotated>0&&(0,d.jsxs)(`span`,{className:`card-aside`,children:[e.rotated,` already rotated`]}),children:e.exposed.length===0?(0,d.jsx)(s,{title:t?`Nothing left to rotate`:`No current values seen`,children:e.rotated>0?`Every value ${r} saw has had a new version since.`:`${n?`They have`:`It has`} not read or written a value that is still current.`}):(0,d.jsx)(`div`,{className:`dt-wrap`,children:(0,d.jsxs)(`table`,{className:`dt report-values`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Secret`}),(0,d.jsx)(`th`,{className:`col-shrink`,children:`Version`}),(0,d.jsx)(`th`,{className:`col-shrink`,children:`Last seen`})]})}),(0,d.jsx)(`tbody`,{children:e.exposed.map(e=>(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`td`,{children:(0,d.jsxs)(o,{className:`cell-link mono`,to:`/projects/$project/$environment`,params:{project:e.project,environment:e.environment},search:{filter:e.key},children:[(0,d.jsxs)(`span`,{className:`report-path`,children:[e.project,`/`,e.environment,`/`]}),e.key]})}),(0,d.jsxs)(`td`,{className:`col-shrink cell-mono cell-muted`,children:[`v`,e.version]}),(0,d.jsxs)(`td`,{className:`col-shrink nowrap`,children:[e.how===`wrote`?`Wrote`:`Read`,` `,(0,d.jsx)(l,{iso:e.at,display:`relative`})]})]},`${e.project}/${e.environment}/${e.key}`))})]})})})}function g({report:e,person:t}){return(0,d.jsx)(a,{labelledBy:`created-syncs`,title:t?`Syncs they set up`:`Syncs it set up`,description:`A sync keeps pushing every change to the destination it names, whoever set it up. Check each one still points somewhere you control.`,children:(0,d.jsx)(`div`,{className:`dt-wrap`,children:(0,d.jsxs)(`table`,{className:`dt syncs`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Destination`}),(0,d.jsx)(`th`,{className:`col-shrink`,children:`From`}),(0,d.jsx)(`th`,{className:`col-shrink col-hide-narrow`,children:`Token`})]})}),(0,d.jsx)(`tbody`,{children:e.syncs.map(e=>(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`td`,{children:(0,d.jsxs)(`span`,{className:`cell-account`,children:[(0,d.jsx)(i,{brand:e.brand,size:15}),(0,d.jsxs)(`span`,{className:`cell-stack`,children:[(0,d.jsxs)(`span`,{children:[e.providerLabel,e.paused&&(0,d.jsx)(`span`,{className:`tag`,children:`Paused`})]}),(0,d.jsx)(`small`,{className:`mono`,children:e.destination})]})]})}),(0,d.jsx)(`td`,{className:`col-shrink`,children:(0,d.jsxs)(o,{className:`cell-link mono`,to:`/projects/$project/$environment`,params:{project:e.project,environment:e.environment},children:[e.project,`/`,e.environment]})}),(0,d.jsx)(`td`,{className:`col-shrink col-hide-narrow cell-mono cell-muted`,children:e.credential})]},e.id))})]})})})}function _({report:e}){return(0,d.jsx)(a,{labelledBy:`issued-tokens`,title:`Tokens they issued`,description:`Service tokens they created that still work. Each was shown to them once, when it was made; revoke any they may have kept a copy of.`,children:(0,d.jsx)(`div`,{className:`dt-wrap`,children:(0,d.jsxs)(`table`,{className:`dt report-tokens`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`th`,{children:`Token`}),(0,d.jsx)(`th`,{className:`col-shrink`,children:`Expires`}),(0,d.jsx)(`th`,{className:`col-shrink col-hide-narrow`,children:`Last used`})]})}),(0,d.jsx)(`tbody`,{children:e.issuedTokens.map(e=>(0,d.jsxs)(`tr`,{children:[(0,d.jsx)(`td`,{children:(0,d.jsxs)(`span`,{className:`cell-stack`,children:[(0,d.jsx)(o,{className:`cell-link mono`,to:`/tokens/$token`,params:{token:e.service},children:e.service}),(0,d.jsxs)(`small`,{children:[e.label??`No label`,` · `,(0,d.jsx)(`span`,{className:`mono`,children:e.hint})]})]})}),(0,d.jsx)(`td`,{className:`col-shrink nowrap`,children:(0,d.jsx)(l,{iso:e.expiresAt,display:`relative`})}),(0,d.jsx)(`td`,{className:`col-shrink col-hide-narrow nowrap`,children:e.lastUsedAt===null?(0,d.jsx)(`span`,{className:`cell-muted`,children:`Never`}):(0,d.jsx)(l,{iso:e.lastUsedAt,display:`relative`})})]},e.id))})]})})})}export{m as n,p as r,f as t};
@@ -1 +1 @@
1
- import{$ as e,C as t,F as n,Ot as r,Q as i,Tt as a,a as o,ct as s,i as c,m as l,n as u,ot as d,tt as f,v as p}from"./page-DbSS7pYH.js";import{D as m,a as h,c as g,l as _,o as v,s as y}from"./preload-helper-DduCCcmc.js";import{i as b,o as x,r as S,s as C}from"./coffre-B0SRYkyG.js";import{r as w,t as T}from"./use-action-LiHC8kKH.js";import{a as E,i as D,r as O,s as k}from"./directory--9Q70fmm.js";import{i as A,n as j,o as M,t as N}from"./grants-BxXkQT0q.js";import{r as P,t as F}from"./offboarding-BmFuQEv1.js";var I=r(a(),1);function L(e,t){return Object.hasOwn(e.environments,t)?e.environments[t]:null}function R(e,t){if(e.length===0)return{level:`none`,expiresAt:null,environments:{}};let[n]=e;if(e.length===1&&n.environmentSlug===null&&(n.role===`owner`||n.role===`viewer`||n.role===`developer`))return{level:n.role,expiresAt:n.expiresAt,environments:{}};let r={};for(let n of e){let e=n.environmentSlug;if(e===null||!t.includes(e)||Object.hasOwn(r,e)||n.role!==`viewer`&&n.role!==`developer`)return{level:`custom`,expiresAt:null,environments:{}};r[e]={role:n.role,expiresAt:n.expiresAt}}return{level:`env`,expiresAt:null,environments:r}}function z(e,t,n){if(t===`env`&&(e.level===`viewer`||e.level===`developer`)&&Object.keys(e.environments).length===0){let r={role:e.level,expiresAt:e.expiresAt};return{...e,level:t,environments:Object.fromEntries(n.map(e=>[e,r]))}}return{...e,level:t}}function B(e,t,n){let r={...e.environments};return n===null?delete r[t]:r[t]=n,{...e,environments:r}}function V(e){switch(e.level){case`none`:case`custom`:return[];case`owner`:case`viewer`:case`developer`:return[{role:e.level,environmentSlug:null,expiresAt:e.expiresAt}];case`env`:return Object.entries(e.environments).map(([e,t])=>({environmentSlug:e,...t}))}}function H(e,t){return e===t||e!==null&&t!==null&&Date.parse(e)===Date.parse(t)}function U(e,t){if(t.level===`custom`)return[];let n=e=>`${e.role}@${e.environmentSlug??``}`,r=new Map(V(t).map(e=>[n(e),e])),i=new Map(e.map(e=>[n(e),e])),a=[];for(let[e,t]of r)i.has(e)||a.push({kind:`create`,...t});for(let[e,t]of i){let n=r.get(e);n!==void 0&&!H(t.expiresAt,n.expiresAt)&&a.push({kind:`expiry`,grant:t,expiresAt:n.expiresAt})}for(let[e,t]of i)r.has(e)||a.push({kind:`revoke`,grant:t});return a}function W(e,t){let n=t=>t===null?e:`${e}/${t}`,r=(e,t)=>t===null?e:{role:e,until:t},i={};for(let e of t)e.kind===`revoke`&&(i[n(e.grant.environmentSlug)]=null);for(let e of t)e.kind===`expiry`&&(i[n(e.grant.environmentSlug)]=r(e.grant.role,e.expiresAt)),e.kind===`create`&&(i[n(e.environmentSlug)]=r(e.role,e.expiresAt));return i}function G(e){return e===``?null:new Date(`${e}T23:59:59Z`).toISOString()}function K(e){return e===null?``:e.slice(0,10)}var q=s();async function J(e,t,n,r){let i=(r?.projects??[]).filter(e=>e.permissions.includes(`grant.manage`)),[a,o]=await Promise.all([r?.capabilities.canManageGrants?x(async()=>{try{return{report:await e.members.get(S(t,n))}}catch(e){if(b(e)===404)return{report:null};throw e}}):Promise.resolve(null),Promise.all(i.map(t=>A(e,t.slug)))]);return{report:a,access:o.flatMap(e=>e.ok?[{project:e.project,grants:e.grants.filter(e=>e.principalType===t&&e.principalId===n),grantsError:e.grantsError}]:[])}}function Y({principalType:e,principalId:n,data:r}){let a=d(),{instanceRole:s}=f({from:`__root__`}),{report:l,access:_}=r,v=D[e],y=e===`user`,b=y?`/users`:`/tokens`,x=l?.ok===!0?l.report:null,S=x?.status===`removed`,C=x!==null&&!S?{principalType:e,principalId:n,instanceRole:x.instanceRole,isRootAdmin:x.isRootAdmin,tampered:x.status===`tampered`}:void 0;if(l?.ok===!0&&x===null||l===null&&_.length===0)return(0,q.jsx)(u,{icon:y?(0,q.jsx)(i,{size:18}):(0,q.jsx)(t,{size:18}),label:(0,q.jsx)(`span`,{className:`mono`,children:n}),title:y?`No such user for you`:`No such token for you`,actions:(0,q.jsxs)(m,{className:`btn`,to:b,children:[`All `,y?`users`:`tokens`]}),children:l===null?`A ${v}'s page lists its access to the projects where you manage access, and you manage none.`:`No ${v} by that name has ever been registered here.`});let w=_.flatMap(({project:e,grants:t})=>t.map(t=>({project:e,grant:t}))),T=_.filter(e=>e.grantsError!==null),A=S?[]:_.filter(({project:e,grantsError:t})=>e.archivedAt===null&&t===null);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(c,{lead:(0,q.jsx)(k,{type:e,id:n,size:`lg`}),title:n,meta:S?(0,q.jsx)(`span`,{className:`tag tag-red`,children:`Removed`}):C?.principalType===`user`&&(0,q.jsx)(O,{principal:C}),actions:(A.length>0||C!==void 0)&&(0,q.jsxs)(q.Fragment,{children:[A.length>0&&(0,q.jsx)(X,{principalType:e,principalId:n,access:A}),C!==void 0&&(0,q.jsx)(E,{principal:C,trigger:`btn btn-icon`,onRemoved:()=>a.invalidate()})]})}),l?.ok===!1&&(0,q.jsx)(`div`,{className:`report-notice`,children:(0,q.jsx)(g,{tone:`bad`,children:l.error})}),S&&x!==null&&(0,q.jsx)(P,{report:x}),!S&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h2`,{className:`section-title`,children:`Project access`}),T.map(({project:e,grantsError:t})=>(0,q.jsx)(`div`,{style:{marginBottom:`0.75rem`},children:(0,q.jsxs)(g,{tone:`bad`,children:[(0,q.jsx)(`span`,{className:`mono`,children:e.slug}),`: `,t]})},e.slug)),(0,q.jsx)(`section`,{className:`card`,"aria-label":`Project access`,children:w.length===0?(0,q.jsx)(h,{title:`No project access yet`,children:A.length>0?`Edit access gives this ${v} access to several projects at once.`:`None of the projects where you manage access has a grant for this ${v}.`}):(0,q.jsx)(j,{lead:(0,q.jsxs)(`span`,{className:`th`,children:[(0,q.jsx)(p,{size:14}),`Project`]}),children:w.map(({project:e,grant:t},n)=>(0,q.jsx)(N,{number:n+1,project:e.slug,grant:t,leadLabel:`Project`,lead:(0,q.jsxs)(`span`,{className:`cell-project`,children:[(0,q.jsx)(o,{name:e.slug}),(0,q.jsx)(m,{className:`cell-link`,to:`/projects/$project`,params:{project:e.slug},search:{tab:y?`users`:`tokens`},children:e.name}),e.archivedAt!==null&&(0,q.jsx)(`span`,{className:`tag tag-red`,children:`archived`})]})},t.id))})}),s!==`root-admin`&&(0,q.jsx)(`p`,{className:`hint section-foot`,children:`Only projects where you manage access are listed.`})]}),x!==null&&(0,q.jsx)(F,{report:x})]})}function X({principalType:e,principalId:t,access:r}){let i=C(),[a,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)({}),{pending:u,error:d,setError:f,run:p}=T(),m=D[e],h=r.map(({project:e,grants:t})=>{let n=e.environments.filter(e=>e.details!==null&&e.details.archivedAt===null).map(e=>e.slug),r=R(t,n),i=Object.hasOwn(c,e.slug)?c[e.slug]:r;return{project:e,grants:t,environments:n,held:r,plan:i,changes:U(t,i)}}),g=h.filter(e=>e.changes.length>0);function b(){s(!1),l({}),f(null)}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>s(!0),children:[(0,q.jsx)(n,{size:14}),`Edit access`]}),(0,q.jsx)(y,{open:a,onOpenChange:e=>e?s(!0):b(),title:(0,q.jsxs)(q.Fragment,{children:[`Edit access for `,(0,q.jsx)(`span`,{className:`mono`,children:t})]}),description:`Set what this ${m} can reach on each project you manage, and until when. Saving applies only what you changed.`,wide:!0,children:(0,q.jsxs)(`form`,{className:`form`,onSubmit:n=>{n.preventDefault(),p(()=>i.access.set(S(e,t),Object.assign({},...g.map(({project:e,changes:t})=>W(e.slug,t)))),()=>{w.success(`Updated ${t}’s access on ${g.length} project${g.length===1?``:`s`}`),b()})},children:[(0,q.jsxs)(`ul`,{className:`plan-list`,children:[(0,q.jsxs)(`li`,{className:`plan-head`,"aria-hidden":`true`,children:[(0,q.jsx)(`span`,{children:`Project`}),(0,q.jsx)(`span`,{children:`Access`}),(0,q.jsx)(`span`,{children:`Expires`})]}),h.map(({project:e,grants:t,environments:n,held:r,plan:i,changes:a})=>{let s=`plan-${e.slug}`,c=t=>l(n=>({...n,[e.slug]:t}));return(0,q.jsxs)(`li`,{className:`plan-row${a.length>0?` is-changed`:``}`,children:[(0,q.jsxs)(`label`,{className:`plan-project`,htmlFor:s,children:[(0,q.jsx)(o,{name:e.slug}),(0,q.jsxs)(`span`,{className:`plan-project-text`,children:[(0,q.jsx)(`span`,{className:`plan-project-name`,children:e.name}),r.level===`custom`&&(0,q.jsxs)(`span`,{className:`plan-project-held`,children:[`Holds `,t.map(e=>M(e)).join(`, `)]})]})]}),(0,q.jsxs)(`select`,{id:s,className:`select select-sm`,value:i.level,onChange:e=>c(z(i,e.target.value,n)),children:[r.level===`custom`&&(0,q.jsx)(`option`,{value:`custom`,children:`Keep as is`}),(0,q.jsx)(`option`,{value:`none`,children:`No access`}),(0,q.jsx)(`option`,{value:`owner`,children:`Owner`}),(0,q.jsx)(`option`,{value:`viewer`,children:`Read: all`}),(0,q.jsx)(`option`,{value:`developer`,children:`Write: all`}),n.length>0&&(0,q.jsx)(`option`,{value:`env`,children:`Per environment…`})]}),(i.level===`owner`||i.level===`viewer`||i.level===`developer`)&&(0,q.jsx)(Z,{label:`${e.name} expires`,expiresAt:i.expiresAt,onChange:e=>c({...i,expiresAt:e})}),i.level===`env`&&(0,q.jsx)(`ul`,{className:`plan-envs`,"aria-label":`Environments of ${e.name}`,children:n.map(t=>{let n=L(i,t);return(0,q.jsxs)(`li`,{className:`plan-env`,children:[(0,q.jsx)(`label`,{className:`mono`,htmlFor:`${s}-${t}`,children:t}),(0,q.jsxs)(`select`,{id:`${s}-${t}`,className:`select select-sm`,value:n?.role??``,onChange:e=>{let r=e.target.value;c(B(i,t,r===`viewer`||r===`developer`?{role:r,expiresAt:n?.expiresAt??null}:null))},children:[(0,q.jsx)(`option`,{value:``,children:`No access`}),(0,q.jsx)(`option`,{value:`viewer`,children:`Read`}),(0,q.jsx)(`option`,{value:`developer`,children:`Write`})]}),n!==null&&(0,q.jsx)(Z,{label:`${t} of ${e.name} expires`,expiresAt:n.expiresAt,onChange:e=>c(B(i,t,{...n,expiresAt:e}))})]},t)})}),a.length>0&&(0,q.jsx)(`ul`,{className:`plan-changes`,"aria-label":`Changes to ${e.name}`,children:a.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Q,{change:e})},e.kind===`create`?`+${e.role}@${e.environmentSlug??``}`:e.grant.id))})]},e.slug)})]}),(0,q.jsx)(v,{error:d}),(0,q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,q.jsx)(`button`,{className:`btn`,type:`button`,onClick:b,children:`Cancel`}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:u||g.length===0,children:[u&&(0,q.jsx)(_,{}),`Save changes`]})]})]})})]})}function Z({label:t,expiresAt:n,onChange:r}){let i=K(n);return(0,q.jsxs)(`span`,{className:`expiry${i===``?` is-never`:``}`,children:[(0,q.jsx)(`input`,{className:`input select-sm`,type:`date`,"aria-label":t,min:new Date().toISOString().slice(0,10),value:i,onChange:e=>r(G(e.target.value))}),(0,q.jsx)(`span`,{className:`expiry-never`,"aria-hidden":`true`,children:`Never`}),(0,q.jsx)(`button`,{className:`btn btn-quiet btn-sm btn-icon`,type:`button`,"aria-label":`${t}: never`,title:`Never expires`,onClick:()=>r(null),children:(0,q.jsx)(e,{size:12})})]})}function Q({change:e}){let t=e=>e===null?``:` until ${K(e)}`;switch(e.kind){case`create`:return(0,q.jsxs)(`span`,{className:`tag tag-green`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`+`}),(0,q.jsx)(`span`,{className:`visually-hidden`,children:`Adds`}),M({...e,roleName:e.role}),t(e.expiresAt)]});case`expiry`:return(0,q.jsxs)(`span`,{className:`tag tag-blue`,children:[(0,q.jsx)(l,{size:12}),(0,q.jsx)(`span`,{className:`visually-hidden`,children:`Moves the expiry of`}),M(e.grant),e.expiresAt===null?`, no expiry`:t(e.expiresAt)]});case`revoke`:return(0,q.jsxs)(`span`,{className:`tag tag-red`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`−`}),(0,q.jsx)(`span`,{className:`visually-hidden`,children:`Removes`}),M(e.grant)]})}}export{J as n,Y as t};
1
+ import{$ as e,C as t,F as n,Ot as r,Q as i,Tt as a,a as o,ct as s,i as c,m as l,n as u,ot as d,tt as f,v as p}from"./page-DbSS7pYH.js";import{D as m,a as h,c as g,l as _,o as v,s as y}from"./preload-helper-DduCCcmc.js";import{i as b,o as x,r as S,s as C}from"./coffre-CXkp3Efg.js";import{r as w,t as T}from"./use-action-CUvWPRTx.js";import{a as E,i as D,r as O,s as k}from"./directory-PEjdb8PS.js";import{i as A,n as j,o as M,t as N}from"./grants-4mSkXPU4.js";import{r as P,t as F}from"./offboarding-DQ-56W0H.js";var I=r(a(),1);function L(e,t){return Object.hasOwn(e.environments,t)?e.environments[t]:null}function R(e,t){if(e.length===0)return{level:`none`,expiresAt:null,environments:{}};let[n]=e;if(e.length===1&&n.environmentSlug===null&&(n.role===`owner`||n.role===`viewer`||n.role===`developer`))return{level:n.role,expiresAt:n.expiresAt,environments:{}};let r={};for(let n of e){let e=n.environmentSlug;if(e===null||!t.includes(e)||Object.hasOwn(r,e)||n.role!==`viewer`&&n.role!==`developer`)return{level:`custom`,expiresAt:null,environments:{}};r[e]={role:n.role,expiresAt:n.expiresAt}}return{level:`env`,expiresAt:null,environments:r}}function z(e,t,n){if(t===`env`&&(e.level===`viewer`||e.level===`developer`)&&Object.keys(e.environments).length===0){let r={role:e.level,expiresAt:e.expiresAt};return{...e,level:t,environments:Object.fromEntries(n.map(e=>[e,r]))}}return{...e,level:t}}function B(e,t,n){let r={...e.environments};return n===null?delete r[t]:r[t]=n,{...e,environments:r}}function V(e){switch(e.level){case`none`:case`custom`:return[];case`owner`:case`viewer`:case`developer`:return[{role:e.level,environmentSlug:null,expiresAt:e.expiresAt}];case`env`:return Object.entries(e.environments).map(([e,t])=>({environmentSlug:e,...t}))}}function H(e,t){return e===t||e!==null&&t!==null&&Date.parse(e)===Date.parse(t)}function U(e,t){if(t.level===`custom`)return[];let n=e=>`${e.role}@${e.environmentSlug??``}`,r=new Map(V(t).map(e=>[n(e),e])),i=new Map(e.map(e=>[n(e),e])),a=[];for(let[e,t]of r)i.has(e)||a.push({kind:`create`,...t});for(let[e,t]of i){let n=r.get(e);n!==void 0&&!H(t.expiresAt,n.expiresAt)&&a.push({kind:`expiry`,grant:t,expiresAt:n.expiresAt})}for(let[e,t]of i)r.has(e)||a.push({kind:`revoke`,grant:t});return a}function W(e,t){let n=t=>t===null?e:`${e}/${t}`,r=(e,t)=>t===null?e:{role:e,until:t},i={};for(let e of t)e.kind===`revoke`&&(i[n(e.grant.environmentSlug)]=null);for(let e of t)e.kind===`expiry`&&(i[n(e.grant.environmentSlug)]=r(e.grant.role,e.expiresAt)),e.kind===`create`&&(i[n(e.environmentSlug)]=r(e.role,e.expiresAt));return i}function G(e){return e===``?null:new Date(`${e}T23:59:59Z`).toISOString()}function K(e){return e===null?``:e.slice(0,10)}var q=s();async function J(e,t,n,r){let i=(r?.projects??[]).filter(e=>e.permissions.includes(`grant.manage`)),[a,o]=await Promise.all([r?.capabilities.canManageGrants?x(async()=>{try{return{report:await e.members.get(S(t,n))}}catch(e){if(b(e)===404)return{report:null};throw e}}):Promise.resolve(null),Promise.all(i.map(t=>A(e,t.slug)))]);return{report:a,access:o.flatMap(e=>e.ok?[{project:e.project,grants:e.grants.filter(e=>e.principalType===t&&e.principalId===n),grantsError:e.grantsError}]:[])}}function Y({principalType:e,principalId:n,data:r}){let a=d(),{instanceRole:s}=f({from:`__root__`}),{report:l,access:_}=r,v=D[e],y=e===`user`,b=y?`/users`:`/tokens`,x=l?.ok===!0?l.report:null,S=x?.status===`removed`,C=x!==null&&!S?{principalType:e,principalId:n,instanceRole:x.instanceRole,isRootAdmin:x.isRootAdmin,tampered:x.status===`tampered`}:void 0;if(l?.ok===!0&&x===null||l===null&&_.length===0)return(0,q.jsx)(u,{icon:y?(0,q.jsx)(i,{size:18}):(0,q.jsx)(t,{size:18}),label:(0,q.jsx)(`span`,{className:`mono`,children:n}),title:y?`No such user for you`:`No such token for you`,actions:(0,q.jsxs)(m,{className:`btn`,to:b,children:[`All `,y?`users`:`tokens`]}),children:l===null?`A ${v}'s page lists its access to the projects where you manage access, and you manage none.`:`No ${v} by that name has ever been registered here.`});let w=_.flatMap(({project:e,grants:t})=>t.map(t=>({project:e,grant:t}))),T=_.filter(e=>e.grantsError!==null),A=S?[]:_.filter(({project:e,grantsError:t})=>e.archivedAt===null&&t===null);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(c,{lead:(0,q.jsx)(k,{type:e,id:n,size:`lg`}),title:n,meta:S?(0,q.jsx)(`span`,{className:`tag tag-red`,children:`Removed`}):C?.principalType===`user`&&(0,q.jsx)(O,{principal:C}),actions:(A.length>0||C!==void 0)&&(0,q.jsxs)(q.Fragment,{children:[A.length>0&&(0,q.jsx)(X,{principalType:e,principalId:n,access:A}),C!==void 0&&(0,q.jsx)(E,{principal:C,trigger:`btn btn-icon`,onRemoved:()=>a.invalidate()})]})}),l?.ok===!1&&(0,q.jsx)(`div`,{className:`report-notice`,children:(0,q.jsx)(g,{tone:`bad`,children:l.error})}),S&&x!==null&&(0,q.jsx)(P,{report:x}),!S&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h2`,{className:`section-title`,children:`Project access`}),T.map(({project:e,grantsError:t})=>(0,q.jsx)(`div`,{style:{marginBottom:`0.75rem`},children:(0,q.jsxs)(g,{tone:`bad`,children:[(0,q.jsx)(`span`,{className:`mono`,children:e.slug}),`: `,t]})},e.slug)),(0,q.jsx)(`section`,{className:`card`,"aria-label":`Project access`,children:w.length===0?(0,q.jsx)(h,{title:`No project access yet`,children:A.length>0?`Edit access gives this ${v} access to several projects at once.`:`None of the projects where you manage access has a grant for this ${v}.`}):(0,q.jsx)(j,{lead:(0,q.jsxs)(`span`,{className:`th`,children:[(0,q.jsx)(p,{size:14}),`Project`]}),children:w.map(({project:e,grant:t},n)=>(0,q.jsx)(N,{number:n+1,project:e.slug,grant:t,leadLabel:`Project`,lead:(0,q.jsxs)(`span`,{className:`cell-project`,children:[(0,q.jsx)(o,{name:e.slug}),(0,q.jsx)(m,{className:`cell-link`,to:`/projects/$project`,params:{project:e.slug},search:{tab:y?`users`:`tokens`},children:e.name}),e.archivedAt!==null&&(0,q.jsx)(`span`,{className:`tag tag-red`,children:`archived`})]})},t.id))})}),s!==`root-admin`&&(0,q.jsx)(`p`,{className:`hint section-foot`,children:`Only projects where you manage access are listed.`})]}),x!==null&&(0,q.jsx)(F,{report:x})]})}function X({principalType:e,principalId:t,access:r}){let i=C(),[a,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)({}),{pending:u,error:d,setError:f,run:p}=T(),m=D[e],h=r.map(({project:e,grants:t})=>{let n=e.environments.filter(e=>e.details!==null&&e.details.archivedAt===null).map(e=>e.slug),r=R(t,n),i=Object.hasOwn(c,e.slug)?c[e.slug]:r;return{project:e,grants:t,environments:n,held:r,plan:i,changes:U(t,i)}}),g=h.filter(e=>e.changes.length>0);function b(){s(!1),l({}),f(null)}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>s(!0),children:[(0,q.jsx)(n,{size:14}),`Edit access`]}),(0,q.jsx)(y,{open:a,onOpenChange:e=>e?s(!0):b(),title:(0,q.jsxs)(q.Fragment,{children:[`Edit access for `,(0,q.jsx)(`span`,{className:`mono`,children:t})]}),description:`Set what this ${m} can reach on each project you manage, and until when. Saving applies only what you changed.`,wide:!0,children:(0,q.jsxs)(`form`,{className:`form`,onSubmit:n=>{n.preventDefault(),p(()=>i.access.set(S(e,t),Object.assign({},...g.map(({project:e,changes:t})=>W(e.slug,t)))),()=>{w.success(`Updated ${t}’s access on ${g.length} project${g.length===1?``:`s`}`),b()})},children:[(0,q.jsxs)(`ul`,{className:`plan-list`,children:[(0,q.jsxs)(`li`,{className:`plan-head`,"aria-hidden":`true`,children:[(0,q.jsx)(`span`,{children:`Project`}),(0,q.jsx)(`span`,{children:`Access`}),(0,q.jsx)(`span`,{children:`Expires`})]}),h.map(({project:e,grants:t,environments:n,held:r,plan:i,changes:a})=>{let s=`plan-${e.slug}`,c=t=>l(n=>({...n,[e.slug]:t}));return(0,q.jsxs)(`li`,{className:`plan-row${a.length>0?` is-changed`:``}`,children:[(0,q.jsxs)(`label`,{className:`plan-project`,htmlFor:s,children:[(0,q.jsx)(o,{name:e.slug}),(0,q.jsxs)(`span`,{className:`plan-project-text`,children:[(0,q.jsx)(`span`,{className:`plan-project-name`,children:e.name}),r.level===`custom`&&(0,q.jsxs)(`span`,{className:`plan-project-held`,children:[`Holds `,t.map(e=>M(e)).join(`, `)]})]})]}),(0,q.jsxs)(`select`,{id:s,className:`select select-sm`,value:i.level,onChange:e=>c(z(i,e.target.value,n)),children:[r.level===`custom`&&(0,q.jsx)(`option`,{value:`custom`,children:`Keep as is`}),(0,q.jsx)(`option`,{value:`none`,children:`No access`}),(0,q.jsx)(`option`,{value:`owner`,children:`Owner`}),(0,q.jsx)(`option`,{value:`viewer`,children:`Read: all`}),(0,q.jsx)(`option`,{value:`developer`,children:`Write: all`}),n.length>0&&(0,q.jsx)(`option`,{value:`env`,children:`Per environment…`})]}),(i.level===`owner`||i.level===`viewer`||i.level===`developer`)&&(0,q.jsx)(Z,{label:`${e.name} expires`,expiresAt:i.expiresAt,onChange:e=>c({...i,expiresAt:e})}),i.level===`env`&&(0,q.jsx)(`ul`,{className:`plan-envs`,"aria-label":`Environments of ${e.name}`,children:n.map(t=>{let n=L(i,t);return(0,q.jsxs)(`li`,{className:`plan-env`,children:[(0,q.jsx)(`label`,{className:`mono`,htmlFor:`${s}-${t}`,children:t}),(0,q.jsxs)(`select`,{id:`${s}-${t}`,className:`select select-sm`,value:n?.role??``,onChange:e=>{let r=e.target.value;c(B(i,t,r===`viewer`||r===`developer`?{role:r,expiresAt:n?.expiresAt??null}:null))},children:[(0,q.jsx)(`option`,{value:``,children:`No access`}),(0,q.jsx)(`option`,{value:`viewer`,children:`Read`}),(0,q.jsx)(`option`,{value:`developer`,children:`Write`})]}),n!==null&&(0,q.jsx)(Z,{label:`${t} of ${e.name} expires`,expiresAt:n.expiresAt,onChange:e=>c(B(i,t,{...n,expiresAt:e}))})]},t)})}),a.length>0&&(0,q.jsx)(`ul`,{className:`plan-changes`,"aria-label":`Changes to ${e.name}`,children:a.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Q,{change:e})},e.kind===`create`?`+${e.role}@${e.environmentSlug??``}`:e.grant.id))})]},e.slug)})]}),(0,q.jsx)(v,{error:d}),(0,q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,q.jsx)(`button`,{className:`btn`,type:`button`,onClick:b,children:`Cancel`}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:u||g.length===0,children:[u&&(0,q.jsx)(_,{}),`Save changes`]})]})]})})]})}function Z({label:t,expiresAt:n,onChange:r}){let i=K(n);return(0,q.jsxs)(`span`,{className:`expiry${i===``?` is-never`:``}`,children:[(0,q.jsx)(`input`,{className:`input select-sm`,type:`date`,"aria-label":t,min:new Date().toISOString().slice(0,10),value:i,onChange:e=>r(G(e.target.value))}),(0,q.jsx)(`span`,{className:`expiry-never`,"aria-hidden":`true`,children:`Never`}),(0,q.jsx)(`button`,{className:`btn btn-quiet btn-sm btn-icon`,type:`button`,"aria-label":`${t}: never`,title:`Never expires`,onClick:()=>r(null),children:(0,q.jsx)(e,{size:12})})]})}function Q({change:e}){let t=e=>e===null?``:` until ${K(e)}`;switch(e.kind){case`create`:return(0,q.jsxs)(`span`,{className:`tag tag-green`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`+`}),(0,q.jsx)(`span`,{className:`visually-hidden`,children:`Adds`}),M({...e,roleName:e.role}),t(e.expiresAt)]});case`expiry`:return(0,q.jsxs)(`span`,{className:`tag tag-blue`,children:[(0,q.jsx)(l,{size:12}),(0,q.jsx)(`span`,{className:`visually-hidden`,children:`Moves the expiry of`}),M(e.grant),e.expiresAt===null?`, no expiry`:t(e.expiresAt)]});case`revoke`:return(0,q.jsxs)(`span`,{className:`tag tag-red`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`−`}),(0,q.jsx)(`span`,{className:`visually-hidden`,children:`Removes`}),M(e.grant)]})}}export{J as n,Y as t};
@@ -1,3 +1,3 @@
1
- import{$ as e,B as t,C as n,D as r,F as i,I as a,J as o,K as s,L as c,M as l,Ot as u,P as d,Tt as f,Y as p,_ as m,b as h,c as g,ct as _,g as v,i as y,l as b,m as x,n as S,ot as C,q as w,s as ee,t as T,tt as E,x as D,z as O}from"./page-DbSS7pYH.js";import{D as te,a as ne,c as k,d as A,f as j,g as M,i as re,l as N,m as P,n as F,o as I,r as L,s as R,u as z}from"./preload-helper-DduCCcmc.js";import{c as ie,d as ae,f as B,l as V,m as H,n as U,o as W,p as G,s as K,t as q}from"./coffre-B0SRYkyG.js";import{r as J,t as Y}from"./use-action-LiHC8kKH.js";import{i as X,o as oe}from"./affordances-CmoY-8Xf.js";import{t as se}from"./projects._project._environment-CAHNmhje.js";import{t as ce}from"./validation-9Cl_XS-l.js";var le=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/;function ue(e){let t=[],n=[],r=new Set,i=e.split(/\r\n|\n|\r/);for(let e=0;e<i.length;e++){let a=e+1,o=i[e].trim();if(o===``||o.startsWith(`#`))continue;let s=o.startsWith(`export `)?o.slice(7).trim():o,c=s.indexOf(`=`);if(c===-1){n.push({line:a,text:o,reason:`no "=" on this line`});continue}let l=s.slice(0,c).trim();if(!le.test(l)){n.push({line:a,text:l,reason:`key must match ^[A-Za-z_][A-Za-z0-9_]*$`});continue}let u=s.slice(c+1).trim(),d;if(u.startsWith(`"`)){let e=fe(u,`"`);if(e===-1){n.push({line:a,text:l,reason:`unterminated double quote (multi-line values are not supported)`});continue}if(d=pe(u.slice(1,e)),de(u.slice(e+1))){n.push({line:a,text:l,reason:`unexpected text after the closing quote`});continue}}else if(u.startsWith(`'`)){let e=u.indexOf(`'`,1);if(e===-1){n.push({line:a,text:l,reason:`unterminated single quote (multi-line values are not supported)`});continue}if(d=u.slice(1,e),de(u.slice(e+1))){n.push({line:a,text:l,reason:`unexpected text after the closing quote`});continue}}else{let e=u.indexOf(` #`);e!==-1&&(u=u.slice(0,e)),d=u.trim()}if(d.includes(`\0`)){n.push({line:a,text:l,reason:`value contains a NUL byte, which cannot be passed in an environment`});continue}if(r.has(l)){n.push({line:a,text:l,reason:`duplicate key in this file`});continue}r.add(l),t.push({key:l,value:d,line:a})}return{entries:t,problems:n}}function de(e){let t=e.trim();return t!==``&&!t.startsWith(`#`)}function fe(e,t){for(let n=1;n<e.length;n++){if(e[n]===`\\`){n++;continue}if(e[n]===t)return n}return-1}function pe(e){return e.replace(/\\(.)/g,(e,t)=>{switch(t){case`n`:return`
1
+ import{$ as e,B as t,C as n,D as r,F as i,I as a,J as o,K as s,L as c,M as l,Ot as u,P as d,Tt as f,Y as p,_ as m,b as h,c as g,ct as _,g as v,i as y,l as b,m as x,n as S,ot as C,q as w,s as ee,t as T,tt as E,x as D,z as O}from"./page-DbSS7pYH.js";import{D as te,a as ne,c as k,d as A,f as j,g as M,i as re,l as N,m as P,n as F,o as I,r as L,s as R,u as z}from"./preload-helper-DduCCcmc.js";import{c as ie,d as ae,f as B,l as V,m as H,n as U,o as W,p as G,s as K,t as q}from"./coffre-CXkp3Efg.js";import{r as J,t as Y}from"./use-action-CUvWPRTx.js";import{i as X,o as oe}from"./affordances-CmoY-8Xf.js";import{t as se}from"./projects._project._environment-CLUpTvi-.js";import{t as ce}from"./validation-9Cl_XS-l.js";var le=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/;function ue(e){let t=[],n=[],r=new Set,i=e.split(/\r\n|\n|\r/);for(let e=0;e<i.length;e++){let a=e+1,o=i[e].trim();if(o===``||o.startsWith(`#`))continue;let s=o.startsWith(`export `)?o.slice(7).trim():o,c=s.indexOf(`=`);if(c===-1){n.push({line:a,text:o,reason:`no "=" on this line`});continue}let l=s.slice(0,c).trim();if(!le.test(l)){n.push({line:a,text:l,reason:`key must match ^[A-Za-z_][A-Za-z0-9_]*$`});continue}let u=s.slice(c+1).trim(),d;if(u.startsWith(`"`)){let e=fe(u,`"`);if(e===-1){n.push({line:a,text:l,reason:`unterminated double quote (multi-line values are not supported)`});continue}if(d=pe(u.slice(1,e)),de(u.slice(e+1))){n.push({line:a,text:l,reason:`unexpected text after the closing quote`});continue}}else if(u.startsWith(`'`)){let e=u.indexOf(`'`,1);if(e===-1){n.push({line:a,text:l,reason:`unterminated single quote (multi-line values are not supported)`});continue}if(d=u.slice(1,e),de(u.slice(e+1))){n.push({line:a,text:l,reason:`unexpected text after the closing quote`});continue}}else{let e=u.indexOf(` #`);e!==-1&&(u=u.slice(0,e)),d=u.trim()}if(d.includes(`\0`)){n.push({line:a,text:l,reason:`value contains a NUL byte, which cannot be passed in an environment`});continue}if(r.has(l)){n.push({line:a,text:l,reason:`duplicate key in this file`});continue}r.add(l),t.push({key:l,value:d,line:a})}return{entries:t,problems:n}}function de(e){let t=e.trim();return t!==``&&!t.startsWith(`#`)}function fe(e,t){for(let n=1;n<e.length;n++){if(e[n]===`\\`){n++;continue}if(e[n]===t)return n}return-1}function pe(e){return e.replace(/\\(.)/g,(e,t)=>{switch(t){case`n`:return`
2
2
  `;case`r`:return`\r`;case`\\`:case`"`:case`'`:return t;default:return e}})}var Z=u(f(),1);function Q(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function me(e,t,n){let r=e.filter(e=>!Q(n,e.key)?.archived).map(e=>Q(n,e.key)?.key.trim()??e.key);if(new Set(r).size!==r.length)return!0;let i=t.map(e=>e.key.trim());if(new Set(i).size!==i.length)return!0;let a=new Set(e.flatMap(e=>{let t=Q(n,e.key);return t!==void 0&&!t.archived&&t.value!==null?[t.key.trim()]:[]}));if(i.some(e=>a.has(e)))return!0;let o=new Set(e.filter(e=>Q(n,e.key)?.archived).map(e=>e.key));return i.some(e=>o.has(e))}async function he({active:e,drafts:t,changes:n,operations:r}){let i={...n},a=ge(e,t,n);if(a instanceof Error)return{applied:0,drafts:[...t],changes:i,error:a};let o=0,s=Object.create(null);try{for(let{sourceKey:e,change:t}of a){if(t.archived){s[e]=null;continue}let n=t.key.trim();n!==e&&(await r.rename(e,n),delete i[e],o+=1,t.value!==null&&(i[n]={key:n,value:t.value,archived:!1})),t.value!==null&&(s[n]=t.value)}for(let e of t)s[e.key.trim()]=e.value;let e=Object.keys(s).length;return e>0&&await r.write({...s}),{applied:o+e,drafts:[],changes:{},error:null}}catch(e){return{applied:o,drafts:[...t],changes:i,error:e}}}function ge(e,t,n){let r=new Set(e.map(e=>e.key)),i=new Set(e.filter(e=>Q(n,e.key)?.archived).map(e=>e.key)),a=t.find(e=>i.has(e.key.trim()));if(a)return Error(`${a.key.trim()}: cannot archive and write the same key in one save`);let o=new Map,s=[];for(let t of e){let e=Q(n,t.key);e!==void 0&&(!e.archived&&e.key.trim()!==t.key?o.set(t.key,e):s.push({sourceKey:t.key,change:e}))}for(let[e,t]of o){let n=t.key.trim();if(r.has(n)&&!o.has(n))return Error(`${e}: ${n} is already in use`)}let c=[],l=new Set;for(;o.size>0;){let e=[...o].find(([,e])=>{let t=e.key.trim();return!r.has(t)||l.has(t)});if(!e)return Error(`Secret renames contain a cycle. Save them in separate steps.`);let[t,n]=e;o.delete(t),l.add(t),c.push({sourceKey:t,change:n})}return[...c,...s]}function _e(e,t){return e!==null&&e.version===t}var $=_(),ve=2e3,ye=6e4;function be({project:e,environment:t,result:n,canRun:r}){let i=C(),a=n.ok&&n.syncs.some(e=>e.running);if((0,Z.useEffect)(()=>{if(!a)return;let e=setInterval(()=>void i.invalidate(),ve);return()=>clearInterval(e)},[a,i]),n.ok&&n.syncs.length===0&&!n.canManage)return null;let o=n.ok&&n.canManage;return(0,$.jsx)(T,{labelledBy:`syncs`,title:`Syncs`,description:`Destinations these secrets are pushed to. A change goes out when it is saved, and every hour coffre checks each destination and repairs what drifted.`,actions:o?(0,$.jsx)(De,{project:e,environment:t}):void 0,children:n.ok?n.syncs.length===0?(0,$.jsxs)(ne,{title:`Not synced anywhere`,children:[`Push these secrets where your code runs, such as GitHub Actions or Vercel, and keep them current there. Anything else can read them with `,(0,$.jsx)(`code`,{children:`coffre run`}),`.`]}):(0,$.jsx)(`div`,{className:`dt-wrap`,children:(0,$.jsxs)(`table`,{className:`dt syncs stacks`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{children:`Destination`}),(0,$.jsx)(`th`,{className:`col-shrink`,children:`Status`}),(0,$.jsx)(`th`,{className:`col-shrink col-hide-narrow`,children:`Token`}),(0,$.jsx)(`th`,{className:`col-actions`,children:(0,$.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,$.jsx)(`tbody`,{children:n.syncs.map(e=>(0,$.jsx)(xe,{sync:e,canRun:r,canManage:o},e.id))})]})}):(0,$.jsx)(`div`,{className:`card-body`,children:(0,$.jsx)(I,{error:n.error})})})}function xe({sync:t,canRun:n,canManage:r}){let[i,o]=(0,Z.useState)(!1),c=K(),u=Y(),f=Y(),p=u.pending||f.pending,m=u.error??f.error;function h(){u.run(()=>c.syncs.run(t.id),e=>we(t,e.outcome))}function g(e){f.run(()=>c.syncs.update(t.id,{paused:e}),()=>J.success(e?`Paused ${t.destination}`:`Resumed ${t.destination}`,{action:{label:`Undo`,onClick:()=>g(!e)}}))}let _=m??(t.offered?t.lastError:null);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`tr`,{className:_!==null&&!t.running?`has-error`:void 0,children:[(0,$.jsx)(`td`,{className:`col-destination`,children:(0,$.jsxs)(`span`,{className:`cell-account`,children:[(0,$.jsx)(w,{brand:t.brand,size:15}),(0,$.jsxs)(`span`,{className:`cell-stack`,children:[(0,$.jsx)(`span`,{children:t.providerLabel}),t.offered?(0,$.jsx)(`small`,{className:`mono`,children:t.destination}):(0,$.jsx)(`small`,{children:`No longer offered by this deployment`})]})]})}),(0,$.jsx)(`td`,{className:`nowrap col-status`,children:(0,$.jsxs)(`span`,{className:`cell-stack`,children:[(0,$.jsx)(Se,{sync:t}),(0,$.jsx)(`small`,{children:(0,$.jsx)(Ce,{sync:t})})]})}),(0,$.jsx)(`td`,{className:`col-shrink col-hide-narrow cell-mono cell-muted`,children:t.credential}),(0,$.jsxs)(`td`,{className:`col-actions`,children:[(0,$.jsxs)(`div`,{className:`acts`,children:[n&&!t.paused&&(0,$.jsxs)(`button`,{className:`act`,onClick:h,disabled:p||t.running||!t.offered,title:t.offered?void 0:`This deployment no longer offers this provider`,children:[u.pending?(0,$.jsx)(N,{size:13}):(0,$.jsx)(s,{size:13}),`Run now`]}),r&&(0,$.jsxs)(M.Root,{children:[(0,$.jsx)(M.Trigger,{asChild:!0,children:(0,$.jsx)(`button`,{className:`act act-icon act-quiet`,"aria-label":`More for ${t.destination}`,disabled:p,children:(0,$.jsx)(l,{size:16})})}),(0,$.jsx)(M.Portal,{children:(0,$.jsxs)(M.Content,{className:`menu`,sideOffset:6,align:`end`,children:[(0,$.jsxs)(M.Item,{className:`menu-item`,onSelect:()=>g(!t.paused),children:[t.paused?(0,$.jsx)(a,{size:14}):(0,$.jsx)(d,{size:14}),t.paused?`Resume`:`Pause`]}),(0,$.jsx)(M.Separator,{className:`menu-sep`}),(0,$.jsxs)(M.Item,{className:`menu-item menu-item-danger`,onSelect:()=>o(!0),children:[(0,$.jsx)(e,{size:14}),`Remove`]})]})})]})]}),(0,$.jsx)(L,{open:i,onOpenChange:o,title:(0,$.jsxs)($.Fragment,{children:[`Stop syncing to `,(0,$.jsx)(`span`,{className:`mono`,children:t.destination}),`?`]}),body:`Nothing more is pushed to ${t.providerLabel}. Keys coffre already pushed stay there; remove them at ${t.providerLabel} if they should go too.`,confirmLabel:`Remove sync`,onConfirm:()=>f.run(()=>c.syncs.remove(t.id),()=>J.success(`No longer syncing to ${t.destination}`))})]})]}),_!==null&&!t.running&&(0,$.jsx)(`tr`,{className:`row-error`,children:(0,$.jsx)(`td`,{colSpan:4,children:(0,$.jsx)(I,{error:_})})})]})}function Se({sync:e}){return e.offered?e.running?(0,$.jsxs)(`span`,{className:`tag tag-blue`,children:[(0,$.jsx)(N,{size:11}),`Pushing`]}):e.paused?(0,$.jsx)(`span`,{className:`tag tag-outline`,children:`Paused`}):e.lastStatus===`failed`?(0,$.jsx)(`span`,{className:`tag tag-red`,children:`Failed`}):e.pending>0?(0,$.jsxs)(`span`,{className:`tag tag-amber`,children:[e.pending,` pending`]}):e.lastStatus===`partial`?(0,$.jsx)(`span`,{className:`tag tag-amber`,children:`Partial`}):e.lastRunAt===null?(0,$.jsx)(`span`,{className:`tag`,children:`Not run yet`}):(0,$.jsx)(`span`,{className:`tag tag-green`,children:`In sync`}):(0,$.jsx)(`span`,{className:`tag tag-outline`,children:`Unavailable`})}function Ce({sync:e}){let t=e.skipped.length,n=[];return(e.synced>0||e.pending===0)&&n.push(`${e.synced} synced`),e.pending>0&&n.push(`${e.pending} pending`),t>0&&n.push((0,$.jsx)(j,{label:(0,$.jsx)(`ul`,{style:{margin:0,paddingLeft:`1rem`},children:e.skipped.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`mono`,children:e.key}),`: `,e.reason]},e.key))}),children:(0,$.jsxs)(`button`,{type:`button`,className:`tag tag-amber tag-button`,children:[(0,$.jsx)(g,{size:11}),t,` skipped`]})})),e.lastRunAt!==null&&n.push((0,$.jsx)(z,{iso:e.lastRunAt,display:`relative`})),(0,$.jsx)($.Fragment,{children:n.map((e,t)=>(0,$.jsxs)(Z.Fragment,{children:[t>0&&` · `,e]},t))})}function we(e,t){if(t.status===`busy`){J(`A run is already under way`,{description:`Its result appears here when it ends.`});return}let n=t.upserted.length+t.deleted.length;if(t.status===`failed`)J.error(`Could not sync to ${e.destination}`,{description:t.error??void 0});else if(t.status===`partial`)J.warning(`${t.failed.length} of ${n+t.failed.length} changes failed`,{description:t.failed[0]?.message});else if(n===0)J.success(`${e.destination} was already current`);else{let n=[t.upserted.length>0&&`pushed ${t.upserted.length}`,t.deleted.length>0&&`removed ${t.deleted.length}`].filter(Boolean);J.success(`${Ee(n.join(`, `))} to ${e.destination}`)}}async function Te(e,t,n,r){let i=J.loading(`Pushing to ${n.destination}`,{description:`The first push is under way.`}),a=Date.now()+ye;for(;Date.now()<a;){await new Promise(e=>setTimeout(e,ve));let a=await W(()=>e.syncs.list(t)),o=a.ok?a.syncs.find(e=>e.id===n.id):void 0;if(!(o===void 0||o.running||o.lastRunAt===null)){await r(),o.lastStatus===`failed`?J.error(`Could not sync to ${n.destination}`,{id:i,description:o.lastError??void 0}):o.lastStatus===`partial`?J.warning(`Synced to ${n.destination}, but not every key`,{id:i,description:o.lastError??void 0}):J.success(`Synced to ${n.destination}`,{id:i,description:`${o.synced} ${o.synced===1?`key is`:`keys are`} there now.`});return}}await r(),J(`Still pushing to ${n.destination}`,{id:i,description:`Its result appears in the list when it ends.`})}function Ee(e){return e.charAt(0).toUpperCase()+e.slice(1)}function De({project:e,environment:t}){let[n,r]=(0,Z.useState)(!1);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{className:`btn btn-sm`,onClick:()=>r(!0),children:[(0,$.jsx)(c,{size:14}),`Add sync`]}),(0,$.jsx)(R,{open:n,onOpenChange:r,title:(0,$.jsxs)($.Fragment,{children:[`Sync `,(0,$.jsxs)(`span`,{className:`mono`,children:[e,`/`,t]})]}),description:`Every key in this environment is pushed to the destination and kept current. coffre only ever removes keys it pushed itself.`,wide:!0,children:(0,$.jsx)(Oe,{children:n=>(0,$.jsx)(ke,{project:e,environment:t,providers:n,onDone:()=>r(!1)})})})]})}function Oe({children:e}){let t=K(),[n,r]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=!0;return W(()=>t.syncs.providers()).then(t=>{e&&r(t)}),()=>{e=!1}},[t]),n===null?(0,$.jsxs)(`p`,{className:`picker-empty sync-providers-state`,children:[(0,$.jsx)(N,{size:13}),`Loading where coffre can sync to…`]}):n.ok?n.providers.length===0?(0,$.jsxs)(`p`,{className:`picker-empty sync-providers-state`,children:[`This instance offers nowhere to sync to. Whoever runs coffre lists the providers in its`,` `,(0,$.jsx)(`span`,{className:`mono`,children:`syncs`}),` settings.`]}):e(n.providers):(0,$.jsx)(`div`,{className:`sync-providers-state`,children:(0,$.jsx)(I,{error:n.error})})}function ke({project:e,environment:t,providers:n,onDone:r}){let[i,a]=(0,Z.useState)(n[0]),[o,s]=(0,Z.useState)(()=>B(n[0])),[c,l]=(0,Z.useState)(``),u=K(),d=C(),{pending:f,error:p,setError:m,run:h}=Y(),g=ae(i,o);function _(e){a(e),s(B(e)),m(null)}function v(e,t){s(n=>({...n,[e]:t}))}return(0,$.jsxs)(`form`,{className:`form`,style:{marginTop:`1.25rem`},onSubmit:n=>{n.preventDefault(),h(()=>u.syncs.add(`${e}/${t}`,{provider:i.id,config:V(i,o),credential:c.trim()}),n=>{r(),Te(u,`${e}/${t}`,n,()=>d.invalidate())})},children:[n.length>1&&(0,$.jsx)(`div`,{className:`choice-grid sync-providers`,role:`group`,"aria-label":`Destination`,children:n.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`choice`,"aria-pressed":e.id===i.id,onClick:()=>_(e),children:[(0,$.jsx)(w,{brand:e.brand}),e.label]},e.id))}),(0,$.jsx)(`div`,{className:`form-row`,children:i.fields.map(e=>{if(!G(e,o))return null;if(e.type===`text`)return(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsxs)(`span`,{className:`label`,children:[e.label,e.optional===!0&&(0,$.jsx)(`span`,{className:`hint`,children:` (optional)`})]}),(0,$.jsx)(`input`,{className:`input input-mono`,value:o[e.name],placeholder:e.placeholder,spellCheck:!1,autoComplete:`off`,onChange:t=>v(e.name,t.target.value)}),e.hint!==void 0&&(0,$.jsx)(`span`,{className:`hint`,children:e.hint})]},`${i.id}.${e.name}`);let t=o[e.name];return(0,$.jsxs)(`div`,{className:`field field-options`,role:`group`,"aria-label":e.label,children:[(0,$.jsx)(`span`,{className:`label`,children:e.label}),(0,$.jsx)(`div`,{className:`segmented`,children:e.options.map(n=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":t.includes(n.value),onClick:()=>v(e.name,e.multiple?t.includes(n.value)?t.filter(e=>e!==n.value):[...t,n.value]:[n.value]),children:n.label},n.value))}),e.hint!==void 0&&(0,$.jsx)(`span`,{className:`hint`,children:e.hint})]},`${i.id}.${e.name}`)})}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{className:`label`,children:`Token`}),(0,$.jsx)(`input`,{className:`input input-mono`,value:c,placeholder:i.credential.placeholder,spellCheck:!1,autoComplete:`off`,onChange:e=>l(e.target.value)}),(0,$.jsxs)(`span`,{className:`hint`,children:[`The secret that holds it, as `,(0,$.jsx)(`code`,{children:`project/environment/KEY`}),`. An environment of its own, such as `,(0,$.jsx)(`code`,{children:`ops/sync`}),`, keeps it from everyone who reads these secrets. You need read access to it.`]})]}),(0,$.jsx)(k,{tone:`info`,children:i.credential.hint}),(0,$.jsx)(I,{error:p}),(0,$.jsxs)(`div`,{className:`dialog-actions`,children:[(0,$.jsx)(`button`,{className:`btn`,type:`button`,onClick:r,children:`Cancel`}),(0,$.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:f||g!==null||c.trim()===``,title:g===null?void 0:`${g} is required`,children:[f&&(0,$.jsx)(N,{}),`Start syncing`]})]})]})}var Ae=45;function je(){let{keys:e,syncs:t}=se.useLoaderData(),{project:n,environment:i}=se.useParams();return e.ok?(0,$.jsx)(Me,{project:n,environment:i,permissions:e.permissions,keys:e.keys,syncs:t},`${n}/${i}`):(0,$.jsx)(S,{icon:(0,$.jsx)(r,{size:18}),label:(0,$.jsxs)(`span`,{className:`mono`,children:[n,`/`,i]}),title:`This environment is closed to you`,actions:(0,$.jsxs)(te,{className:`btn`,to:`/projects/$project`,params:{project:n},children:[`Back to `,n]}),children:e.error})}function Me({project:e,environment:i,permissions:a,keys:s,syncs:l}){let u=C(),d=K(),f=`${e}/${i}`,[p,m]=(0,Z.useState)([]),[g,_]=(0,Z.useState)({}),[v,b]=(0,Z.useState)(()=>new Set),[S,w]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(null),[O,te]=(0,Z.useState)(se.useSearch().filter??``),k=(0,Z.useRef)(0),A=a.includes(`secret.write`),j=a.includes(`secret.archive`),M=oe(a),P=s.filter(e=>!e.archived),F=s.filter(e=>e.archived),I=new Set(s.map(e=>e.key)),L=P.filter(e=>Q(g,e.key)!==void 0),R=me(P,p,g),z=[...p.map(e=>e.key.trim()),...L.flatMap(e=>{let t=Q(g,e.key);return t===void 0||t.archived?[]:[t.key.trim()]})],ie=z.some(e=>e===``),ae=z.some(e=>e!==``&&ce(e)!==null),B=p.length+L.length,V=B>0&&!ie&&!ae&&!R;function H(e,t){_(n=>{let r={...Q(n,e.key)??{key:e.key,value:null,archived:!1},...t};if(r.key!==e.key||r.value!==null||r.archived)return{...n,[e.key]:r};let{[e.key]:i,...a}=n;return a})}function W(e){_(t=>{let{[e]:n,...r}=t;return r}),b(t=>{let n=new Set(t);return n.delete(e),n})}function G(){m(e=>[{id:k.current++,key:``,value:``},...e])}function Y(){m([]),_({}),b(new Set),D(null)}async function X(){if(!V||S)return;w(!0),D(null);let e=await he({active:P,drafts:p,changes:g,operations:{rename:async(e,t)=>{try{await d.secrets.rename(`${f}/${e}`,t)}catch(t){throw new q(`${e}: ${U(t)}`)}},write:async e=>{try{await d.secrets.set(f,e)}catch(e){throw new q(U(e))}}}});if(m(e.drafts),_(e.changes),b(new Set),e.applied>0)try{await u.invalidate()}catch{D(`Saved, but the page could not refresh. Reload before you retry.`),w(!1);return}if(e.error===null)J.success(`Saved ${B} change${B===1?``:`s`}`);else{let t=e.error instanceof Error?e.error.message:`The request could not be sent.`;D(e.applied===0?t:`${t} The renames before it were saved; nothing else was, and the rest is ready to retry.`)}w(!1)}let le=(0,Z.useRef)(X);le.current=X,(0,Z.useEffect)(()=>{if(B===0)return;function e(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),le.current())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[B]);let ue=[...p.map(e=>({key:e.key.trim()||`unnamed`,what:I.has(e.key.trim())?`new version`:`added`})),...L.map(e=>{let t=Q(g,e.key);if(t.archived)return{key:e.key,what:`archived`};let n=t.key.trim()!==e.key;return n&&t.value!==null?{key:e.key,what:`→ ${t.key.trim()}, new value`}:n?{key:e.key,what:`→ ${t.key.trim()}`}:{key:e.key,what:`new value`}})],de=ie?null:R?`Two pending edits would end up with the same name. Secret names are unique in an environment.`:ae?`Names are letters, digits and underscores, and cannot start with a digit.`:null,fe=O.trim().toLowerCase(),pe=fe===``?P:P.filter(e=>e.key.toLowerCase().includes(fe));return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{tile:e,title:i,aside:(0,$.jsx)(Ne,{project:e,environment:i}),actions:(0,$.jsxs)($.Fragment,{children:[A&&M&&(0,$.jsx)(We,{project:e,environment:i}),A&&(0,$.jsxs)(`button`,{className:`btn btn-primary`,onClick:G,disabled:S,children:[(0,$.jsx)(c,{size:14}),`New secret`]})]})}),(P.length>0||p.length>0)&&(0,$.jsxs)(`div`,{className:`toolbar`,children:[(0,$.jsxs)(`label`,{className:`filter input-group`,children:[(0,$.jsx)(`span`,{className:`visually-hidden`,children:`Filter secrets by name`}),(0,$.jsx)(t,{size:14,className:`input-icon`}),(0,$.jsx)(`input`,{className:`input`,type:`search`,placeholder:`Filter by name…`,spellCheck:!1,autoComplete:`off`,value:O,onChange:e=>te(e.target.value)})]}),(0,$.jsx)(`div`,{className:`toolbar-meta`,children:(0,$.jsxs)(`span`,{className:`th`,title:`Run a process with these secrets in its environment`,children:[(0,$.jsx)(o,{size:14}),(0,$.jsxs)(`code`,{children:[`coffre run `,e,`/`,i,` -- …`]}),(0,$.jsx)(re,{value:`coffre run ${e}/${i} -- `,label:`Copy command`})]})})]}),(0,$.jsx)(`section`,{className:`card`,"aria-label":`Secrets`,children:P.length===0&&p.length===0?(0,$.jsx)(ne,{title:`No secrets yet`,actions:A?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{className:`btn btn-primary`,onClick:G,children:[(0,$.jsx)(c,{size:14}),`New secret`]}),M&&(0,$.jsx)(We,{project:e,environment:i})]}):void 0,children:A?`Add them one by one, or import an existing .env file. Nothing is written until you save, or until you have seen the import plan.`:`Nothing has been written to this environment, and adding the first secret needs secret.write.`}):(0,$.jsx)(`div`,{className:`dt-wrap`,children:(0,$.jsxs)(`table`,{className:`dt secrets stacks`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{className:`n`,children:`#`}),(0,$.jsx)(`th`,{className:`col-key`,children:(0,$.jsxs)(`span`,{className:`th`,children:[(0,$.jsx)(n,{size:14}),`Key`]})}),(0,$.jsx)(`th`,{children:(0,$.jsxs)(`span`,{className:`th`,children:[(0,$.jsx)(r,{size:14}),`Value`,!M&&(0,$.jsx)(`span`,{className:`th-note`,children:`hidden from you`})]})}),(0,$.jsx)(`th`,{className:`col-version`,children:(0,$.jsxs)(`span`,{className:`th`,children:[(0,$.jsx)(h,{size:14}),`Version`]})}),(0,$.jsx)(`th`,{className:`col-written col-hide-narrow`,children:(0,$.jsxs)(`span`,{className:`th`,children:[(0,$.jsx)(x,{size:14}),`Last written`]})}),(0,$.jsx)(`th`,{className:`col-actions`,children:(0,$.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,$.jsxs)(`tbody`,{children:[p.map(e=>(0,$.jsx)(ze,{draft:e,existingVersion:s.find(t=>t.key===e.key.trim())?.version??null,disabled:S,onChange:t=>m(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>m(t=>t.filter(t=>t.id!==e.id))},e.id)),pe.map(t=>{let n=Q(g,t.key);return(0,$.jsx)(Le,{number:P.indexOf(t)+1,project:e,environment:i,entry:t,change:n??{key:t.key,value:null,archived:!1},editing:n?.archived!==!0&&(v.has(t.key)||n!==void 0),canWrite:A,canArchive:j,canReveal:M,disabled:S,columns:6,onEdit:()=>b(e=>new Set(e).add(t.key)),onPatch:e=>H(t,e),onUndo:()=>W(t.key),onMarkArchive:()=>{b(e=>{let n=new Set(e);return n.delete(t.key),n}),_(e=>({...e,[t.key]:{key:t.key,value:null,archived:!0}}))}},t.key)}),pe.length===0&&P.length>0&&(0,$.jsx)(`tr`,{children:(0,$.jsxs)(`td`,{colSpan:6,className:`cell-muted`,style:{padding:`1rem`},children:[`No secret name contains “`,O.trim(),`”.`]})})]})]})})}),(0,$.jsx)(be,{project:e,environment:i,result:l,canRun:A||a.includes(`environment.manage`)}),F.length>0&&(0,$.jsx)(T,{labelledBy:`archived-secrets`,title:`Archived`,description:(0,$.jsxs)($.Fragment,{children:[`Retired, so no longer served or injected by `,(0,$.jsx)(`code`,{children:`coffre run`}),`. Their history and audit trail are intact, and restoring is immediate.`]}),children:(0,$.jsx)(`div`,{className:`dt-wrap`,children:(0,$.jsxs)(`table`,{className:`dt secrets secrets-archived stacks`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{className:`n`,children:`#`}),(0,$.jsx)(`th`,{className:`col-key`,children:(0,$.jsxs)(`span`,{className:`th`,children:[(0,$.jsx)(n,{size:14}),`Key`]})}),(0,$.jsx)(`th`,{className:`col-version`,children:(0,$.jsxs)(`span`,{className:`th`,children:[(0,$.jsx)(h,{size:14}),`Version`]})}),(0,$.jsx)(`th`,{className:`col-written col-hide-narrow`,children:(0,$.jsxs)(`span`,{className:`th`,children:[(0,$.jsx)(x,{size:14}),`Last written`]})}),(0,$.jsx)(`th`,{className:`col-actions`,children:(0,$.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,$.jsx)(`tbody`,{children:F.map((t,n)=>(0,$.jsx)(Be,{number:n+1,project:e,environment:i,entry:t,canArchive:j,canReveal:M},t.key))})]})})}),B>0&&(0,$.jsx)(`div`,{className:`savebar`,role:`region`,"aria-label":`Unsaved changes`,children:(0,$.jsxs)(`div`,{className:`savebar-inner`,children:[(0,$.jsxs)(`span`,{className:`savebar-count`,children:[(0,$.jsx)(`span`,{className:`dot`,"aria-hidden":!0}),B,` unsaved change`,B===1?``:`s`]}),(0,$.jsxs)(`span`,{className:`savebar-summary`,children:[ue.slice(0,3).map((e,t)=>(0,$.jsxs)(`span`,{children:[t>0&&` · `,(0,$.jsx)(`span`,{className:`mono`,children:e.key}),` `,e.what]},`${e.key}:${t}`)),ue.length>3&&` · and ${ue.length-3} more`]}),(0,$.jsxs)(`div`,{className:`savebar-actions`,children:[(0,$.jsx)(`button`,{className:`btn btn-sm`,onClick:Y,disabled:S,children:`Discard`}),(0,$.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:()=>void X(),disabled:S||!V,title:`Save (⌘ Enter or Ctrl Enter)`,"aria-keyshortcuts":`Meta+Enter Control+Enter`,children:[S&&(0,$.jsx)(N,{size:13}),`Save `,B===1?`change`:`${B} changes`]})]}),(E??de)!==null&&(0,$.jsxs)(`p`,{className:`savebar-error`,role:`alert`,children:[(0,$.jsx)(ee,{size:14}),(0,$.jsx)(`span`,{children:E??de})]})]})})]})}function Ne({project:e,environment:t}){let{projects:n}=E({from:`__root__`}),r=n.find(t=>t.slug===e)?.environments.find(e=>e.slug===t)?.name;return r===void 0?null:(0,$.jsx)($.Fragment,{children:r})}function Pe({masked:e,className:t=``,...n}){let[r,i]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{i(typeof CSS<`u`&&CSS.supports(`-webkit-text-security`,`disc`))},[]),(0,$.jsx)(`input`,{...n,type:e&&!r?`password`:`text`,className:`${t}${e&&r?` is-masked`:``}`,autoComplete:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0})}function Fe({label:e,value:t,onChange:n,placeholder:r,disabled:i,autoFocus:a,onEscape:o}){let[s,c]=(0,Z.useState)(!1);return(0,$.jsxs)(`div`,{className:`input-group`,children:[(0,$.jsx)(Pe,{className:`input input-mono`,masked:!s,"aria-label":e,placeholder:r,value:t,disabled:i,autoFocus:a,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Escape`&&o!==void 0&&o()}}),(0,$.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-sm btn-icon input-addon`,"aria-label":s?`Mask the value`:`Show the value`,"aria-pressed":s,onClick:()=>c(e=>!e),children:s?(0,$.jsx)(m,{size:14}):(0,$.jsx)(v,{size:14})})]})}function Ie(e){let[t,n]=(0,Z.useState)(()=>Date.now());return(0,Z.useEffect)(()=>{if(e===null)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e===null?0:Math.max(0,Math.ceil(Ae-(t-e.at)/1e3))}function Le({number:t,project:n,environment:r,entry:a,change:o,editing:s,canWrite:c,canArchive:u,canReveal:d,disabled:f,columns:p,onEdit:h,onPatch:g,onUndo:_,onMarkArchive:y}){let[x,S]=(0,Z.useState)(null),C=K(),[w,ee]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(null),[k,j]=(0,Z.useState)(null),F=_e(x,a.version)?x:null;(0,Z.useEffect)(()=>{x!==null&&!_e(x,a.version)&&S(null)},[x,a.version]),(0,Z.useEffect)(()=>{if(x===null)return;let e=setTimeout(()=>S(null),Ae*1e3);return()=>clearTimeout(e)},[x]);let L=Ie(F),R=s&&_e(k,a.version)?k:null;(0,Z.useEffect)(()=>{s||j(null)},[s]);async function z(){if(F!==null)return F.value;ee(!0);try{let{values:e}=await C.secrets.reveal(`${n}/${r}/${a.key}`),t=e[a.key];return ne(null),S({value:t,version:a.version,at:Date.now()}),t}catch(e){return ne(e instanceof ie?U(e):`The request could not be sent. Nothing was read.`),null}finally{ee(!1)}}function ae(){F===null?z():S(null)}let B=o.archived,V=o.key!==a.key,H=o.value!==null,W=s?ce(o.key.trim()):null,G=B?` is-leaving`:s&&(V||H)?` is-changed`:F===null?``:` is-revealed`,q=a.version??0;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`tr`,{className:`secret-row${G}`,children:[(0,$.jsx)(`td`,{className:`n`,children:t}),(0,$.jsx)(`td`,{className:`cell-key`,"data-label":`Key`,children:s&&c?(0,$.jsxs)(`div`,{className:`edit-stack`,children:[(0,$.jsx)(`input`,{className:`input input-mono`,"aria-label":`Name for ${a.key}`,"aria-invalid":W!==null,spellCheck:!1,autoComplete:`off`,value:o.key,disabled:f,onChange:e=>g({key:e.target.value}),onKeyDown:e=>{e.key===`Escape`&&_()}}),(W!==null||V)&&(0,$.jsx)(`span`,{className:`edit-note${W===null?``:` edit-note-error`}`,children:W??(0,$.jsxs)($.Fragment,{children:[`Renamed from `,(0,$.jsx)(`span`,{className:`mono`,children:a.key})]})})]}):(0,$.jsxs)(`div`,{className:`key-cell`,children:[(0,$.jsx)(`span`,{children:P(a.key)}),B&&(0,$.jsx)(`span`,{className:`tag tag-red`,children:`will be archived`})]})}),(0,$.jsx)(`td`,{"data-label":`Value`,children:s&&c?(0,$.jsxs)(`div`,{className:`edit-stack`,children:[(0,$.jsx)(Fe,{label:`New value for ${a.key}`,value:o.value??R?.value??``,placeholder:`New value`,disabled:f,autoFocus:!0,onChange:e=>g({value:e===(R?.value??``)?null:e}),onEscape:_}),(0,$.jsxs)(`span`,{className:`edit-note`,children:[(0,$.jsx)(`span`,{children:H?`Saving appends v${q+1}; v${q} stays restorable.`:R===null?`Nothing is decrypted to edit. Left empty, v${q} stays current.`:`This is v${q}. Change it to append v${q+1}.`}),d&&!H&&R===null&&(0,$.jsxs)(`button`,{type:`button`,className:`act`,disabled:w,onClick:async()=>{let e=await z();e!==null&&j({value:e,version:a.version,at:Date.now()})},children:[w&&(0,$.jsx)(N,{size:12}),`Start from current value`]})]})]}):F!==null&&!B?(0,$.jsxs)(`div`,{className:`revealed`,style:{"--reveal-ttl":`${Ae}s`},children:[(0,$.jsx)(`span`,{className:`revealed-value`,children:F.value===``?`(empty)`:F.value}),(0,$.jsxs)(`span`,{className:`revealed-note`,children:[`Hides in `,L,`s`]}),(0,$.jsx)(`span`,{className:`revealed-meter`,"aria-hidden":!0})]}):(0,$.jsx)(`span`,{className:`mask`,"aria-label":`Hidden`,children:`••••••••••••`})}),(0,$.jsx)(`td`,{className:`col-version`,"data-label":`Version`,children:s&&H?(0,$.jsxs)(`span`,{className:`version-shift`,children:[`v`,q,` → `,(0,$.jsxs)(`b`,{children:[`v`,q+1]})]}):(0,$.jsx)(`span`,{className:`version-shift`,children:a.version===null?`—`:`v${a.version}`})}),(0,$.jsx)(`td`,{className:`col-written col-hide-narrow`,"data-label":`Last written`,children:(0,$.jsx)(Re,{entry:a})}),(0,$.jsx)(`td`,{className:`col-actions`,children:(0,$.jsx)(`div`,{className:`acts`,children:B?(0,$.jsx)(A,{label:`Keep`,children:(0,$.jsx)(`button`,{className:`act act-icon act-quiet`,onClick:_,disabled:f,"aria-label":`Keep ${a.key}`,children:(0,$.jsx)(O,{size:14})})}):s?(0,$.jsx)(A,{label:V||H?`Undo changes`:`Cancel`,children:(0,$.jsx)(`button`,{className:`act act-icon act-quiet`,onClick:_,disabled:f,"aria-label":`${V||H?`Undo changes to`:`Stop editing`} ${a.key}`,children:V||H?(0,$.jsx)(O,{size:14}):(0,$.jsx)(e,{size:15})})}):(0,$.jsxs)($.Fragment,{children:[F!==null&&(0,$.jsx)(re,{variant:`act`,value:F.value,label:`Copy ${a.key}`}),(0,$.jsx)(X,{canReveal:d,children:(0,$.jsx)(A,{label:F===null?`Reveal`:`Hide`,children:(0,$.jsx)(`button`,{className:`act act-icon act-accent`,onClick:ae,disabled:w,"aria-label":`${F===null?`Reveal`:`Hide`} ${a.key}`,children:w?(0,$.jsx)(N,{size:13}):F===null?(0,$.jsx)(v,{size:15}):(0,$.jsx)(m,{size:15})})})}),c&&(0,$.jsx)(A,{label:`Edit`,children:(0,$.jsx)(`button`,{className:`act act-icon`,onClick:()=>{F!==null&&j(F),S(null),h()},disabled:f,"aria-label":`Edit ${a.key}`,children:(0,$.jsx)(i,{size:14})})}),(d||u)&&(0,$.jsxs)(M.Root,{children:[(0,$.jsx)(M.Trigger,{asChild:!0,children:(0,$.jsx)(`button`,{className:`act act-icon act-quiet`,"aria-label":`More for ${a.key}`,disabled:f,children:(0,$.jsx)(l,{size:16})})}),(0,$.jsx)(M.Portal,{children:(0,$.jsxs)(M.Content,{className:`menu`,sideOffset:6,align:`end`,children:[(0,$.jsx)(X,{canReveal:d,children:(0,$.jsxs)(M.Item,{className:`menu-item`,onSelect:()=>E(e=>!e),children:[(0,$.jsx)(D,{size:14}),T?`Hide history`:`Version history`]})}),u&&(0,$.jsxs)($.Fragment,{children:[d&&(0,$.jsx)(M.Separator,{className:`menu-sep`}),(0,$.jsxs)(M.Item,{className:`menu-item menu-item-danger`,onSelect:()=>{S(null),y()},children:[(0,$.jsx)(b,{size:14}),`Archive`,(0,$.jsx)(`span`,{className:`menu-hint`,children:`on save`})]})]})]})})]})]})})})]}),T&&d&&(0,$.jsx)(`tr`,{className:`detail-row`,children:(0,$.jsx)(`td`,{colSpan:p,children:(0,$.jsx)(Ve,{project:n,environment:r,secretKey:a.key,currentVersion:a.version,canWrite:c,onClose:()=>E(!1),onRolledBack:()=>S(null)})})}),te!==null&&(0,$.jsx)(`tr`,{className:`row-error`,children:(0,$.jsx)(`td`,{colSpan:p,children:(0,$.jsx)(I,{error:te})})})]})}function Re({entry:e}){if(e.updatedBy===null&&e.updatedAt===null)return(0,$.jsx)(`span`,{className:`cell-muted`,children:`—`});let t=e.updatedBy??`unknown`;return(0,$.jsxs)(`span`,{className:`written`,children:[(0,$.jsx)(`span`,{className:`written-by`,title:t,children:t.split(`@`)[0]}),e.updatedAt!==null&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`cell-muted`,"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`cell-muted`,children:(0,$.jsx)(z,{iso:e.updatedAt,display:`relative`})})]})]})}function ze({draft:t,existingVersion:n,disabled:r,onChange:i,onRemove:a}){let[o,s]=(0,Z.useState)(!1),c=t.key.trim(),l=c===``?o?`Give it a name.`:null:ce(c),u=c!==``&&n!==null;return(0,$.jsxs)(`tr`,{className:`secret-row is-draft`,children:[(0,$.jsx)(`td`,{className:`n`,"aria-label":`New`,children:`+`}),(0,$.jsx)(`td`,{className:`cell-key`,"data-label":`New secret`,children:(0,$.jsxs)(`div`,{className:`edit-stack`,children:[(0,$.jsx)(`input`,{className:`input input-mono`,autoFocus:!0,"aria-label":`Name of the new secret`,"aria-invalid":l!==null,placeholder:`NAME_OF_SECRET`,spellCheck:!1,autoComplete:`off`,value:t.key,disabled:r,onBlur:()=>s(!0),onChange:e=>i({key:e.target.value}),onKeyDown:e=>{e.key===`Escape`&&a()}}),(l!==null||u)&&(0,$.jsx)(`span`,{className:`edit-note${l===null?``:` edit-note-error`}`,children:l??`This name already exists here. Saving appends a new version to it rather than creating a second secret.`})]})}),(0,$.jsx)(`td`,{"data-label":`Value`,children:(0,$.jsx)(`div`,{className:`edit-stack`,children:(0,$.jsx)(Fe,{label:`Value for ${c===``?`the new secret`:c}`,value:t.value,placeholder:`Value`,disabled:r,onChange:e=>i({value:e}),onEscape:a})})}),(0,$.jsx)(`td`,{className:`col-version`,"data-label":`Version`,children:(0,$.jsx)(`span`,{className:`version-shift`,children:u?(0,$.jsxs)($.Fragment,{children:[`v`,n,` → `,(0,$.jsxs)(`b`,{children:[`v`,n+1]})]}):(0,$.jsx)(`b`,{children:`new`})})}),(0,$.jsx)(`td`,{className:`col-written col-hide-narrow`,children:(0,$.jsx)(`span`,{className:`cell-muted`,children:`—`})}),(0,$.jsx)(`td`,{className:`col-actions`,children:(0,$.jsx)(`div`,{className:`acts`,children:(0,$.jsx)(A,{label:`Remove`,children:(0,$.jsx)(`button`,{className:`act act-icon act-quiet`,onClick:a,disabled:r,"aria-label":c===``?`Remove this new secret`:`Remove new secret ${c}`,children:(0,$.jsx)(e,{size:15})})})})})]})}function Be({number:e,project:t,environment:n,entry:r,canArchive:i,canReveal:a}){let[o,s]=(0,Z.useState)(!1),c=K(),{pending:l,error:u,run:d}=Y();function f(e){d(()=>c.secrets.update(`${t}/${n}/${r.key}`,{archived:e}),()=>J.success(e?`${r.key} archived`:`${r.key} restored`,{action:{label:`Undo`,onClick:()=>f(!e)}}))}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`tr`,{className:`secret-row is-archived`,children:[(0,$.jsx)(`td`,{className:`n`,children:e}),(0,$.jsx)(`td`,{className:`cell-key`,"data-label":`Key`,children:P(r.key)}),(0,$.jsx)(`td`,{className:`col-version`,"data-label":`Version`,children:(0,$.jsx)(`span`,{className:`version-shift`,children:r.version===null?`—`:`v${r.version}`})}),(0,$.jsx)(`td`,{className:`col-written col-hide-narrow`,"data-label":`Last written`,children:(0,$.jsx)(Re,{entry:r})}),(0,$.jsx)(`td`,{className:`col-actions`,children:(0,$.jsxs)(`div`,{className:`acts`,children:[(0,$.jsx)(X,{canReveal:a,children:(0,$.jsx)(A,{label:o?`Hide history`:`Version history`,children:(0,$.jsx)(`button`,{className:`act act-icon act-quiet`,onClick:()=>s(e=>!e),"aria-label":`${o?`Hide history of`:`Version history of`} ${r.key}`,"aria-expanded":o,children:(0,$.jsx)(D,{size:15})})})}),i&&(0,$.jsx)(A,{label:`Restore`,children:(0,$.jsx)(`button`,{className:`act act-icon`,onClick:()=>f(!1),disabled:l,"aria-label":`Restore ${r.key}`,children:l?(0,$.jsx)(N,{size:13}):(0,$.jsx)(O,{size:14})})})]})})]}),o&&(0,$.jsx)(`tr`,{className:`detail-row`,children:(0,$.jsx)(`td`,{colSpan:5,children:(0,$.jsx)(Ve,{project:t,environment:n,secretKey:r.key,currentVersion:r.version,canWrite:!1,onClose:()=>s(!1),onRolledBack:()=>void 0})})}),u!==null&&(0,$.jsx)(`tr`,{className:`row-error`,children:(0,$.jsx)(`td`,{colSpan:5,children:(0,$.jsx)(I,{error:u})})})]})}function Ve({project:e,environment:t,secretKey:n,currentVersion:r,canWrite:i,onClose:a,onRolledBack:o}){let[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=K(),{pending:f,error:p,run:m}=Y();return(0,Z.useEffect)(()=>{let r=!1;return d.secrets.history(`${e}/${t}/${n}`).then(e=>{r||(c(e.versions),u(null))}).catch(e=>{r||u(e instanceof ie?U(e):`The version history could not be loaded.`)}),()=>{r=!0}},[d,e,t,n,r]),(0,$.jsxs)(`div`,{className:`history`,children:[(0,$.jsxs)(`div`,{className:`history-head`,children:[(0,$.jsxs)(`span`,{className:`history-title th`,children:[(0,$.jsx)(D,{size:14}),`Versions of `,(0,$.jsx)(`span`,{className:`mono`,children:n})]}),(0,$.jsx)(`button`,{className:`act`,onClick:a,children:`Close`})]}),l===null?s===null?(0,$.jsxs)(`p`,{className:`hint history-body`,children:[(0,$.jsx)(N,{size:13}),` Loading versions…`]}):(0,$.jsx)(`div`,{className:`dt-wrap`,children:(0,$.jsxs)(`table`,{className:`dt`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{className:`col-shrink`,children:`Version`}),(0,$.jsx)(`th`,{className:`col-shrink`,children:`Written (UTC)`}),(0,$.jsx)(`th`,{children:`By`}),(0,$.jsx)(`th`,{className:`col-shrink`,children:`Key id`}),(0,$.jsx)(`th`,{className:`col-actions`,children:(0,$.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,$.jsx)(`tbody`,{children:s.map(r=>(0,$.jsxs)(`tr`,{children:[(0,$.jsxs)(`td`,{className:`cell-mono nowrap`,children:[`v`,r.version,` `,r.current&&(0,$.jsx)(`span`,{className:`tag tag-blue`,children:`current`})]}),(0,$.jsx)(`td`,{className:`nowrap`,children:(0,$.jsx)(z,{iso:r.createdAt})}),(0,$.jsx)(`td`,{children:r.createdBy}),(0,$.jsx)(`td`,{className:`cell-mono cell-muted nowrap`,children:r.kek}),(0,$.jsx)(`td`,{className:`col-actions`,children:i&&!r.current&&(0,$.jsx)(F,{trigger:(0,$.jsxs)(`button`,{className:`act`,disabled:f,children:[(0,$.jsx)(O,{size:13}),`Roll back`]}),title:(0,$.jsxs)($.Fragment,{children:[`Roll `,(0,$.jsx)(`span`,{className:`mono`,children:n}),` back to v`,r.version,`?`]}),body:(0,$.jsxs)($.Fragment,{children:[`The current pointer moves to v`,r.version,`. Nothing is copied or deleted, every version stays readable, and the next write continues the numbering forward. Anything reading`,` `,(0,$.jsxs)(`span`,{className:`mono`,children:[e,`/`,t]}),` `,`picks up the change immediately.`]}),confirmLabel:`Roll back to v${r.version}`,destructive:!1,onConfirm:()=>m(()=>d.secrets.restore(`${e}/${t}/${n}`,r.version),()=>{o(),J.success(`${n} rolled back to v${r.version}`)})})})]},r.version))})]})}):(0,$.jsx)(`div`,{className:`history-body`,children:(0,$.jsx)(I,{error:l})}),p!==null&&(0,$.jsx)(`div`,{className:`history-body`,children:(0,$.jsx)(I,{error:p})}),(0,$.jsx)(`p`,{className:`history-note`,children:`Metadata only. Listing versions decrypts nothing.`})]})}var He={added:`tag tag-green`,changed:`tag tag-blue`,unchanged:`tag`};async function Ue(e,t,n){let r=ue(n);return r.entries.length===0?{plan:[],changes:{},problems:r.problems}:{...await H(e,t,r.entries),problems:r.problems}}function We({project:e,environment:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!1),u=K(),{pending:d,error:f,setError:m,run:h}=Y(),g=`${e}/${t}`;function _(){h(()=>Ue(u,g,n),e=>{s(e.problems),a({entries:e.plan,changes:e.changes})})}function v(){if(i===null)return;let e=Object.keys(i.changes).length;h(()=>u.secrets.set(g,i.changes),()=>{J.success(`Imported ${e} change${e===1?``:`s`}`),y()})}function y(){l(!1),a(null),r(``),s([]),m(null)}let b=i?.entries.filter(e=>e.action!==`unchanged`)??[];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{className:`btn`,onClick:()=>l(!0),children:[(0,$.jsx)(p,{size:14}),`Import .env`]}),(0,$.jsx)(R,{open:c,onOpenChange:e=>e?l(!0):y(),title:(0,$.jsxs)($.Fragment,{children:[`Import into`,` `,(0,$.jsxs)(`span`,{className:`mono`,children:[e,`/`,t]})]}),wide:!0,description:(0,$.jsx)($.Fragment,{children:`Paste a .env file. It is read by the CLI’s own parser, so this page and the CLI cannot disagree about what it means, and malformed lines are reported rather than guessed at. coffre compares it with the current values without sending any to this page.`}),children:(0,$.jsxs)(`div`,{className:`form`,style:{marginTop:`1.25rem`},children:[(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{className:`label`,children:`File contents`}),(0,$.jsx)(`textarea`,{className:`textarea`,autoFocus:!0,spellCheck:!1,placeholder:`DATABASE_URL=postgres://…
3
3
  STRIPE_KEY="sk_live_…"`,value:n,onChange:e=>{r(e.target.value),a(null),s([])}})]}),i!==null&&i.entries.length>0&&(0,$.jsx)(`div`,{className:`card dt-wrap`,children:(0,$.jsxs)(`table`,{className:`dt`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{children:`Key`}),(0,$.jsx)(`th`,{className:`col-shrink`,children:`Plan`}),(0,$.jsx)(`th`,{className:`col-shrink`,children:`Current`})]})}),(0,$.jsx)(`tbody`,{children:i.entries.map(e=>(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`td`,{className:`cell-key`,children:P(e.key)}),(0,$.jsx)(`td`,{className:`col-shrink`,children:(0,$.jsx)(`span`,{className:He[e.action],children:e.action})}),(0,$.jsx)(`td`,{className:`col-shrink cell-mono cell-muted`,children:e.version===null?`—`:`v${e.version}`})]},e.key))})]})}),i!==null&&i.entries.length>0&&b.length===0&&(0,$.jsx)(k,{tone:`good`,children:`Every key already has this value. There is nothing to write.`}),o.length>0&&(0,$.jsxs)(k,{tone:`bad`,children:[(0,$.jsxs)(`strong`,{children:[o.length,` line`,o.length===1?``:`s`,` could not be parsed`]}),(0,$.jsx)(`ul`,{style:{margin:`0.375rem 0 0`,paddingLeft:`1.1rem`},children:o.map(e=>(0,$.jsxs)(`li`,{children:[`Line `,e.line,`: `,e.reason,` `,(0,$.jsxs)(`span`,{className:`mono`,children:[`(`,e.text,`)`]})]},e.line))})]}),(0,$.jsx)(I,{error:f}),(0,$.jsxs)(`div`,{className:`dialog-actions`,children:[(0,$.jsx)(`button`,{className:`btn`,onClick:y,children:`Cancel`}),i===null?(0,$.jsxs)(`button`,{className:`btn btn-primary`,disabled:d||n.trim()===``,onClick:_,children:[d&&(0,$.jsx)(N,{}),`Preview changes`]}):(0,$.jsxs)(`button`,{className:`btn btn-primary`,disabled:d||b.length===0,onClick:v,children:[d&&(0,$.jsx)(N,{}),`Write `,b.length,` change`,b.length===1?``:`s`]})]})]})})]})}export{je as component};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/projects._project._environment-D5vWbgMo.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/preload-helper-DduCCcmc.js","_coffre/assets/coffre-B0SRYkyG.js","_coffre/assets/use-action-LiHC8kKH.js","_coffre/assets/affordances-CmoY-8Xf.js","_coffre/assets/validation-9Cl_XS-l.js"])))=>i.map(i=>d[i]);
2
- import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{o as r}from"./coffre-B0SRYkyG.js";var i=e(`/projects/$project/$environment`)({validateSearch:e=>({filter:typeof e.filter==`string`&&e.filter!==``?e.filter:void 0}),loader:async({context:{client:e},params:t})=>{let n=`${t.project}/${t.environment}`,[i,a]=await Promise.all([r(()=>e.secrets.list(n)),r(()=>e.syncs.list(n))]);return{keys:i,syncs:a}},component:n(()=>t(()=>import(`./projects._project._environment-D5vWbgMo.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`component`)});export{i as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/projects._project._environment-BZnNvENc.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/preload-helper-DduCCcmc.js","_coffre/assets/coffre-CXkp3Efg.js","_coffre/assets/use-action-CUvWPRTx.js","_coffre/assets/affordances-CmoY-8Xf.js","_coffre/assets/validation-9Cl_XS-l.js"])))=>i.map(i=>d[i]);
2
+ import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{o as r}from"./coffre-CXkp3Efg.js";var i=e(`/projects/$project/$environment`)({validateSearch:e=>({filter:typeof e.filter==`string`&&e.filter!==``?e.filter:void 0}),loader:async({context:{client:e},params:t})=>{let n=`${t.project}/${t.environment}`,[i,a]=await Promise.all([r(()=>e.secrets.list(n)),r(()=>e.syncs.list(n))]);return{keys:i,syncs:a}},component:n(()=>t(()=>import(`./projects._project._environment-BZnNvENc.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`component`)});export{i as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/projects._project.index-BQw4N8k-.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/preload-helper-DduCCcmc.js","_coffre/assets/coffre-B0SRYkyG.js","_coffre/assets/use-action-LiHC8kKH.js","_coffre/assets/project-environments-CfIH5kFM.js","_coffre/assets/directory--9Q70fmm.js","_coffre/assets/grants-BxXkQT0q.js","_coffre/assets/validation-9Cl_XS-l.js"])))=>i.map(i=>d[i]);
2
- import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{i as r}from"./grants-BxXkQT0q.js";var i=e(`/projects/$project/`)({validateSearch:e=>({tab:e.tab===`users`||e.tab===`tokens`||e.tab===`settings`?e.tab:void 0}),loader:({context:{client:e},params:t})=>r(e,t.project),component:n(()=>t(()=>import(`./projects._project.index-BQw4N8k-.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),`component`)});export{i as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/projects._project.index-Dzgf95zv.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/preload-helper-DduCCcmc.js","_coffre/assets/coffre-CXkp3Efg.js","_coffre/assets/use-action-CUvWPRTx.js","_coffre/assets/project-environments-CfIH5kFM.js","_coffre/assets/directory-PEjdb8PS.js","_coffre/assets/grants-4mSkXPU4.js","_coffre/assets/validation-9Cl_XS-l.js"])))=>i.map(i=>d[i]);
2
+ import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{i as r}from"./grants-4mSkXPU4.js";var i=e(`/projects/$project/`)({validateSearch:e=>({tab:e.tab===`users`||e.tab===`tokens`||e.tab===`settings`?e.tab:void 0}),loader:({context:{client:e},params:t})=>r(e,t.project),component:n(()=>t(()=>import(`./projects._project.index-Dzgf95zv.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),`component`)});export{i as t};
@@ -1 +1 @@
1
- import{B as e,C as t,F as n,L as r,M as i,Ot as a,Q as o,Tt as s,V as c,X as l,ct as u,i as d,l as f,n as p,ot as m,t as h,tt as g,u as _,v,w as y,z as b}from"./page-DbSS7pYH.js";import{D as x,a as S,c as C,g as w,l as T,o as E,r as D,s as O}from"./preload-helper-DduCCcmc.js";import{s as k,t as A}from"./coffre-B0SRYkyG.js";import{r as j,t as M}from"./use-action-LiHC8kKH.js";import{t as N}from"./project-environments-CfIH5kFM.js";import{c as P,i as F,o as I,s as L}from"./directory--9Q70fmm.js";import{a as R,n as z,o as B,r as V,s as H,t as U}from"./grants-BxXkQT0q.js";import{t as W}from"./projects._project.index-CnqMmMG7.js";import{n as G}from"./validation-9Cl_XS-l.js";var K=a(s(),1),q=u();function J({principalType:t,canList:n,grants:r,value:i,onChange:a}){let o=k(),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(``),d=(0,K.useId)(),f=F[t],p=t===`user`?`User`:`Token`;if((0,K.useEffect)(()=>{if(!n)return;let e=!0;return I(o,!0).then(t=>{e&&c(t)}),()=>{e=!1}},[n,o]),!n||s?.ok===!1)return(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:t===`user`?`Email`:`Service token common name`}),(0,q.jsx)(`input`,{className:`input input-mono`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:t===`user`?`someone@acme.example`:`ci-deploy`,value:i,onChange:e=>a(e.target.value)}),(0,q.jsxs)(`span`,{className:`hint`,children:[`The `,f,` must already be registered under `,t===`user`?`Users`:`Tokens`,`.`]})]});let m=s?.principals.filter(e=>e.principalType===t)??[],h=l.trim().toLowerCase(),g=m.filter(e=>e.principalId.toLowerCase().includes(h));return(0,q.jsxs)(`fieldset`,{className:`field picker`,children:[(0,q.jsx)(`legend`,{className:`label`,children:p}),(0,q.jsxs)(`label`,{className:`input-group`,children:[(0,q.jsxs)(`span`,{className:`visually-hidden`,children:[`Filter `,f,`s by name`]}),(0,q.jsx)(e,{size:14,className:`input-icon`}),(0,q.jsx)(`input`,{className:`input`,type:`search`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:t===`user`?`Filter by email…`:`Filter by name…`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g.length===1&&(e.preventDefault(),a(g[0].principalId))}})]}),(0,q.jsx)(`div`,{className:`picker-list`,children:s===null?(0,q.jsxs)(`p`,{className:`picker-empty`,children:[(0,q.jsx)(T,{size:13}),`Loading `,f,`s…`]}):m.length===0?(0,q.jsxs)(`p`,{className:`picker-empty`,children:[`No `,f,`s are registered yet.`,` `,(0,q.jsx)(x,{to:t===`user`?`/users`:`/tokens`,children:`Add one`}),` first.`]}):g.length===0?(0,q.jsxs)(`p`,{className:`picker-empty`,children:[`No registered `,f,` matches “`,l.trim(),`”.`]}):g.map(e=>{let n=r.filter(n=>n.principalType===t&&n.principalId===e.principalId).map(B),o=e.principalId===i;return(0,q.jsxs)(`label`,{className:`picker-option${o?` is-chosen`:``}`,children:[(0,q.jsx)(`input`,{type:`radio`,className:`visually-hidden`,name:d,value:e.principalId,checked:o,onChange:()=>a(e.principalId)}),(0,q.jsx)(L,{type:t,id:e.principalId}),(0,q.jsx)(`span`,{className:`picker-name`,children:e.principalId}),n.length>0&&(0,q.jsxs)(`span`,{className:`picker-held`,children:[(0,q.jsx)(`span`,{className:`visually-hidden`,children:`holds`}),n.map(e=>(0,q.jsx)(`span`,{className:`tag`,children:e},e))]}),(0,q.jsx)(_,{size:14,className:`picker-check`})]},e.principalId)})})]})}var Y=[{key:`environments`,label:`Environments`,icon:(0,q.jsx)(y,{size:15})},{key:`users`,label:`Users`,icon:(0,q.jsx)(o,{size:15})},{key:`tokens`,label:`Tokens`,icon:(0,q.jsx)(t,{size:15})},{key:`settings`,label:`Settings`,icon:(0,q.jsx)(c,{size:15})}];function X(){let e=W.useLoaderData(),{project:t}=W.useParams(),n=W.useSearch();if(!e.ok)return(0,q.jsx)(p,{icon:(0,q.jsx)(v,{size:18}),label:(0,q.jsx)(`span`,{className:`mono`,children:t}),title:`No project here for you`,actions:(0,q.jsx)(x,{className:`btn`,to:`/projects`,children:`All projects`}),children:e.error??`There is no such project, or you hold no grant on it. The two look the same on purpose: an answer that told them apart would let anyone list project names.`});let{project:r,grants:i,grantsError:a}=e,o=r.permissions.includes(`project.manage`),s=r.permissions.includes(`environment.manage`),c=r.permissions.includes(`grant.manage`),l=Y.filter(({key:e})=>e===`environments`||(e===`users`||e===`tokens`)&&c||e===`settings`&&o),u=l.find(({key:e})=>e===n.tab)?.key??`environments`,f=u===`users`?`user`:`service`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{tile:r.slug,title:r.name,aside:(0,q.jsx)(`span`,{className:`page-title-slug`,children:r.slug}),actions:u===`environments`?s&&(0,q.jsx)($,{project:r.slug}):(u===`users`||u===`tokens`)&&a===null&&(0,q.jsx)(te,{principalType:f,project:r.slug,environments:r.environments,grants:i})}),r.archivedAt!==null&&(0,q.jsx)(`div`,{style:{marginBottom:`1.25rem`},children:(0,q.jsxs)(C,{tone:`bad`,children:[(0,q.jsx)(`strong`,{children:`This project is archived.`}),` Its environments serve no reads, to people or to machines, until it is restored.`]})}),l.length>1&&(0,q.jsx)(`nav`,{className:`tabs`,"aria-label":`Project sections`,children:l.map(({key:e,label:t,icon:n})=>(0,q.jsxs)(x,{to:`/projects/$project`,params:{project:r.slug},search:{tab:e===`environments`?void 0:e},activeOptions:{exact:!0,explicitUndefined:!0},"aria-current":e===u?`page`:void 0,children:[n,t]},e))}),u===`environments`&&(0,q.jsx)(Z,{project:r,canManage:s}),(u===`users`||u===`tokens`)&&(a===null?(0,q.jsx)(ee,{principalType:f,project:r.slug,grants:i.filter(e=>e.principalType===f)}):(0,q.jsx)(C,{tone:`bad`,children:a})),u===`settings`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ne,{project:r}),(0,q.jsx)(re,{project:r})]})]})}function Z({project:e,canManage:t}){let n=e.environments.filter(N).filter(e=>e.details.archivedAt!==null),r=e.environments.filter(e=>e.details===null||e.details.archivedAt===null);return(0,q.jsxs)(q.Fragment,{children:[r.length===0?(0,q.jsx)(`div`,{className:`card`,children:(0,q.jsx)(S,{title:`No environments yet`,children:t?`Add the first with Add environment.`:`Creating environments needs environment.manage on this project.`})}):(0,q.jsx)(`ul`,{className:`env-grid`,"aria-label":`Environments`,children:r.map(n=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Q,{project:e.slug,environment:n,isAdmin:t})},`${e.slug}:${n.slug}`))}),n.length>0&&(0,q.jsxs)(`section`,{"aria-labelledby":`archived-environments`,children:[(0,q.jsx)(`h2`,{className:`section-title`,id:`archived-environments`,children:`Archived`}),(0,q.jsx)(`ul`,{className:`env-grid`,children:n.map(n=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Q,{project:e.slug,environment:n,isAdmin:t})},n.slug))})]})]})}function Q({project:e,environment:t,isAdmin:r}){let[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(t.slug),[d,p]=(0,K.useState)(t.name),m=k(),{pending:h,error:g,setError:_,run:v}=M(),y=t.details,S=y!==null&&y.archivedAt!==null,C=y?.secretCount??null,A=y!==null&&!S&&t.accessible,N=r&&y!==null,P=l===``?null:G(l);return(0,K.useEffect)(()=>{g!==null&&!a&&j.error(g)},[g,a]),(0,q.jsxs)(`div`,{className:`env-card${A?` is-link`:` is-muted`}`,children:[(0,q.jsxs)(`div`,{className:`env-card-text`,children:[A?(0,q.jsx)(x,{className:`env-card-name stretch`,to:`/projects/$project/$environment`,params:{project:e,environment:t.slug},children:t.name}):(0,q.jsx)(`span`,{className:`env-card-name`,children:t.name}),(0,q.jsxs)(`span`,{className:`env-card-meta`,children:[(0,q.jsx)(`span`,{className:`mono`,children:t.slug}),S?(0,q.jsx)(`span`,{className:`tag tag-red`,children:`archived`}):t.accessible?C!==null&&(0,q.jsxs)(`span`,{children:[C,` secret`,C===1?``:`s`]}):(0,q.jsx)(`span`,{className:`tag tag-outline`,children:`no secret access`})]})]}),N&&(0,q.jsxs)(w.Root,{children:[(0,q.jsx)(w.Trigger,{asChild:!0,children:(0,q.jsx)(`button`,{className:`act act-quiet env-card-menu`,"aria-label":`Actions for ${t.slug}`,disabled:h,children:h?(0,q.jsx)(T,{size:14}):(0,q.jsx)(i,{size:16})})}),(0,q.jsx)(w.Portal,{children:(0,q.jsxs)(w.Content,{className:`menu`,sideOffset:6,align:`end`,children:[(0,q.jsxs)(w.Item,{className:`menu-item`,onSelect:()=>{u(t.slug),p(t.name),o(!0)},children:[(0,q.jsx)(n,{size:14}),`Rename`]}),(0,q.jsx)(w.Separator,{className:`menu-sep`}),(0,q.jsxs)(w.Item,{className:`menu-item${S?``:` menu-item-danger`}`,onSelect:()=>c(!0),children:[S?(0,q.jsx)(b,{size:14}):(0,q.jsx)(f,{size:14}),S?`Restore`:`Archive…`]})]})})]}),N&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{open:a,onOpenChange:e=>{o(e),e||_(null)},title:(0,q.jsxs)(q.Fragment,{children:[`Rename`,` `,(0,q.jsxs)(`span`,{className:`mono`,children:[e,`/`,t.slug]})]}),children:(0,q.jsxs)(`form`,{className:`form`,onSubmit:n=>{n.preventDefault(),v(()=>m.environments.update(`${e}/${t.slug}`,{slug:l,name:d}),()=>{o(!1),j.success(`Environment renamed`)})},children:[(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Slug`}),(0,q.jsx)(`input`,{className:`input input-mono`,autoFocus:!0,spellCheck:!1,value:l,"aria-invalid":P!==null,onChange:e=>u(e.target.value)}),(0,q.jsx)(`span`,{className:`hint${P===null?``:` edit-note-error`}`,children:P??`Anything running coffre run ${e}/${t.slug} will need the new path.`})]}),(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Display name`}),(0,q.jsx)(`input`,{className:`input`,value:d,onChange:e=>p(e.target.value)})]}),(0,q.jsx)(E,{error:g}),(0,q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,q.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>o(!1),children:`Cancel`}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:h||l===``||P!==null||d.trim()===``,children:[h&&(0,q.jsx)(T,{}),`Save`]})]})]})}),(0,q.jsx)(D,{open:s,onOpenChange:c,title:(0,q.jsxs)(q.Fragment,{children:[S?`Restore`:`Archive`,` `,(0,q.jsxs)(`span`,{className:`mono`,children:[e,`/`,t.slug]}),`?`]}),body:C===null?(0,q.jsx)(q.Fragment,{children:`This changes whether the environment serves secrets to principals who have access. Values and history remain stored.`}):S?(0,q.jsxs)(q.Fragment,{children:[`The environment starts serving its `,C,` secret`,C===1?``:`s`,` again, to everyone who holds a grant on it.`]}):(0,q.jsxs)(q.Fragment,{children:[`Its `,C,` secret`,C===1?``:`s`,` stop being served, so anything running `,(0,q.jsx)(`code`,{children:`coffre run`}),` against`,` `,(0,q.jsxs)(`span`,{className:`mono`,children:[e,`/`,t.slug]}),` `,`loses them at its next start. Values and history survive, and restoring is one click.`]}),confirmLabel:S?`Restore environment`:`Archive environment`,destructive:!S,onConfirm:()=>v(()=>m.environments.update(`${e}/${t.slug}`,{archived:!S}),()=>j.success(S?`${t.slug} restored`:`${t.slug} archived`))})]})]})}function $({project:e}){let[t,n]=(0,K.useState)(!1),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(``),c=k(),{pending:l,error:u,setError:d,run:f}=M(),p=i===``?null:G(i);function m(){n(!1),d(null)}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>n(!0),children:[(0,q.jsx)(r,{size:14}),`Add environment`]}),(0,q.jsx)(O,{open:t,onOpenChange:e=>e?n(!0):m(),title:(0,q.jsxs)(q.Fragment,{children:[`New environment in `,(0,q.jsx)(`span`,{className:`mono`,children:e})]}),children:(0,q.jsxs)(`form`,{className:`form`,onSubmit:t=>{t.preventDefault(),f(async()=>{let{created:t}=await c.environments.create(`${e}/${i}`,{name:o});if(!t)throw new A(`An environment named "${i}" already exists.`)},()=>{j.success(`Environment ${i} added`),a(``),s(``),m()})},children:[(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Slug`}),(0,q.jsx)(`input`,{className:`input input-mono`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:`staging`,value:i,"aria-invalid":p!==null,onChange:e=>a(e.target.value)}),(0,q.jsx)(`span`,{className:`hint${p===null?``:` edit-note-error`}`,children:p??(0,q.jsxs)(q.Fragment,{children:[`The CLI will address it as`,` `,(0,q.jsxs)(`span`,{className:`mono`,children:[e,`/`,i===``?`staging`:i]}),`.`]})})]}),(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Display name`}),(0,q.jsx)(`input`,{className:`input`,placeholder:`Staging`,value:o,onChange:e=>s(e.target.value)})]}),(0,q.jsx)(E,{error:u}),(0,q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,q.jsx)(`button`,{className:`btn`,type:`button`,onClick:m,children:`Cancel`}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:l||i===``||p!==null||o.trim()===``,children:[l&&(0,q.jsx)(T,{}),`Add environment`]})]})]})})]})}function ee({principalType:e,project:n,grants:r}){let i=e===`user`;return(0,q.jsx)(`section`,{className:`card`,"aria-label":i?`Users with access`:`Tokens with access`,children:r.length===0?(0,q.jsxs)(S,{title:i?`No user has access`:`No token has access`,children:[`Add `,i?`a user`:`a token`,` with permissions on the whole project or on one environment.`]}):(0,q.jsx)(z,{lead:(0,q.jsxs)(`span`,{className:`th`,children:[i?(0,q.jsx)(l,{size:14}):(0,q.jsx)(t,{size:14}),i?`Email`:`Name`]}),children:r.map((e,t)=>(0,q.jsx)(U,{number:t+1,project:n,grant:e,leadLabel:i?`Email`:`Name`,lead:(0,q.jsx)(P,{type:e.principalType,id:e.principalId})},e.id))})})}function te({principalType:e,project:t,environments:n,grants:i}){let{capabilities:a}=g({from:`__root__`}),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(`viewer:`),[f,p]=(0,K.useState)(``),m=k(),{pending:h,error:_,setError:v,run:y}=M(),b=H(n),x=e===`user`?`user`:`token`;function S(){s(!1),v(null)}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>s(!0),children:[(0,q.jsx)(r,{size:14}),`Add `,x]}),(0,q.jsx)(O,{open:o,onOpenChange:e=>e?s(!0):S(),title:(0,q.jsxs)(q.Fragment,{children:[`Give a `,x,` access to `,(0,q.jsx)(`span`,{className:`mono`,children:t})]}),wide:!0,description:`Owners manage the whole project and its access. Read and write can cover every environment, or one.`,children:(0,q.jsxs)(`form`,{className:`form`,onSubmit:n=>{n.preventDefault();let r=R(u);y(()=>V(m,{project:t,principalType:e,principalId:c.trim(),role:r.role,environmentSlug:r.environmentSlug,expiresAt:f===``?null:new Date(`${f}T23:59:59Z`).toISOString()}),({existed:e})=>{let t=b.find(e=>e.value===u)?.label??`access`;j.success(e?`${c} already has ${t}`:`${c} granted ${t.toLowerCase()}`),l(``),p(``),d(`viewer:`),S()})},children:[(0,q.jsx)(J,{principalType:e,canList:a.canManageGrants,grants:i,value:c,onChange:l}),(0,q.jsxs)(`div`,{className:`form-row`,children:[(0,q.jsxs)(`label`,{className:`field`,style:{flexGrow:2},children:[(0,q.jsx)(`span`,{className:`label`,children:`Permissions`}),(0,q.jsx)(`select`,{className:`select`,value:u,onChange:e=>d(e.target.value),children:b.map(e=>(0,q.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsxs)(`span`,{className:`label`,children:[`Expires `,(0,q.jsx)(`span`,{className:`hint`,children:`(optional)`})]}),(0,q.jsx)(`input`,{className:`input`,type:`date`,value:f,onChange:e=>p(e.target.value)})]})]}),(0,q.jsx)(E,{error:_}),(0,q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,q.jsx)(`button`,{className:`btn`,type:`button`,onClick:S,children:`Cancel`}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:h||c.trim()===``,children:[h&&(0,q.jsx)(T,{}),`Grant access`]})]})]})})]})}function ne({project:e}){let t=m(),[n,r]=(0,K.useState)(e.slug),[i,a]=(0,K.useState)(e.name),o=k(),{pending:s,error:c,run:l}=M(),u=n===``?null:G(n),d=n!==e.slug||i.trim()!==e.name;return(0,K.useEffect)(()=>{r(e.slug),a(e.name)},[e.slug,e.name]),(0,q.jsxs)(`section`,{className:`card`,"aria-labelledby":`general-settings`,children:[(0,q.jsx)(`div`,{className:`card-head`,children:(0,q.jsx)(`div`,{children:(0,q.jsx)(`h2`,{className:`card-title`,id:`general-settings`,children:`General`})})}),(0,q.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),l(()=>o.projects.update(e.slug,{slug:n,name:i}),async()=>{j.success(`Project renamed`),n!==e.slug&&await t.navigate({to:`/projects/$project`,params:{project:n},search:{tab:`settings`}})})},children:[(0,q.jsxs)(`div`,{className:`card-body form-row`,children:[(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Slug`}),(0,q.jsx)(`input`,{className:`input input-mono`,spellCheck:!1,value:n,"aria-invalid":u!==null,onChange:e=>r(e.target.value)}),(0,q.jsx)(`span`,{className:`hint${u===null?``:` edit-note-error`}`,children:u??`Scripts that name the old slug will need the new one.`})]}),(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Display name`}),(0,q.jsx)(`input`,{className:`input`,value:i,onChange:e=>a(e.target.value)})]})]}),(0,q.jsxs)(`div`,{className:`card-foot`,children:[c!==null&&(0,q.jsx)(`span`,{className:`hint`,children:(0,q.jsx)(E,{error:c})}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:!d||s||n===``||u!==null||i.trim()===``,children:[s&&(0,q.jsx)(T,{}),`Save`]})]})]})]})}function re({project:e}){let[t,n]=(0,K.useState)(!1),r=k(),{pending:i,error:a,run:o}=M(),s=e.archivedAt!==null;return(0,q.jsxs)(h,{labelledBy:`danger-zone`,title:`Danger zone`,tone:`danger`,children:[(0,q.jsxs)(`div`,{className:`card-row`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`card-row-title`,children:s?`Restore project`:`Archive project`}),(0,q.jsx)(`p`,{className:`card-row-desc`,children:s?`The project reappears in listings and its environments serve reads again, for everyone who holds a grant on it.`:`Every environment stops serving reads, including to machine callers already running. Nothing is deleted, and you can restore it here at any time.`}),a!==null&&(0,q.jsx)(`div`,{style:{marginTop:`0.5rem`},children:(0,q.jsx)(E,{error:a})})]}),(0,q.jsxs)(`button`,{className:`btn ${s?``:`btn-danger-outline`}`,onClick:()=>n(!0),disabled:i,children:[i?(0,q.jsx)(T,{}):s?(0,q.jsx)(b,{size:14}):(0,q.jsx)(f,{size:14}),s?`Restore project`:`Archive project…`]})]}),(0,q.jsx)(D,{open:t,onOpenChange:n,title:(0,q.jsxs)(q.Fragment,{children:[s?`Restore`:`Archive`,` `,(0,q.jsx)(`span`,{className:`mono`,children:e.slug}),`?`]}),body:s?(0,q.jsx)(q.Fragment,{children:`The project reappears in listings and its environments start serving reads again, for everyone who holds a grant on it.`}):(0,q.jsxs)(q.Fragment,{children:[`Every environment in `,(0,q.jsx)(`span`,{className:`mono`,children:e.slug}),` stops serving reads, including to machine callers already running. Nothing is deleted: values, versions and the audit trail over them stay intact, and you can restore it here at any time.`]}),confirmLabel:s?`Restore project`:`Archive project`,destructive:!s,onConfirm:()=>o(()=>r.projects.update(e.slug,{archived:!s}),()=>j.success(s?`${e.slug} restored`:`${e.slug} archived`))})]})}export{X as component};
1
+ import{B as e,C as t,F as n,L as r,M as i,Ot as a,Q as o,Tt as s,V as c,X as l,ct as u,i as d,l as f,n as p,ot as m,t as h,tt as g,u as _,v,w as y,z as b}from"./page-DbSS7pYH.js";import{D as x,a as S,c as C,g as w,l as T,o as E,r as D,s as O}from"./preload-helper-DduCCcmc.js";import{s as k,t as A}from"./coffre-CXkp3Efg.js";import{r as j,t as M}from"./use-action-CUvWPRTx.js";import{t as N}from"./project-environments-CfIH5kFM.js";import{c as P,i as F,o as I,s as L}from"./directory-PEjdb8PS.js";import{a as R,n as z,o as B,r as V,s as H,t as U}from"./grants-4mSkXPU4.js";import{t as W}from"./projects._project.index-CWXRo307.js";import{n as G}from"./validation-9Cl_XS-l.js";var K=a(s(),1),q=u();function J({principalType:t,canList:n,grants:r,value:i,onChange:a}){let o=k(),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(``),d=(0,K.useId)(),f=F[t],p=t===`user`?`User`:`Token`;if((0,K.useEffect)(()=>{if(!n)return;let e=!0;return I(o,!0).then(t=>{e&&c(t)}),()=>{e=!1}},[n,o]),!n||s?.ok===!1)return(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:t===`user`?`Email`:`Service token common name`}),(0,q.jsx)(`input`,{className:`input input-mono`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:t===`user`?`someone@acme.example`:`ci-deploy`,value:i,onChange:e=>a(e.target.value)}),(0,q.jsxs)(`span`,{className:`hint`,children:[`The `,f,` must already be registered under `,t===`user`?`Users`:`Tokens`,`.`]})]});let m=s?.principals.filter(e=>e.principalType===t)??[],h=l.trim().toLowerCase(),g=m.filter(e=>e.principalId.toLowerCase().includes(h));return(0,q.jsxs)(`fieldset`,{className:`field picker`,children:[(0,q.jsx)(`legend`,{className:`label`,children:p}),(0,q.jsxs)(`label`,{className:`input-group`,children:[(0,q.jsxs)(`span`,{className:`visually-hidden`,children:[`Filter `,f,`s by name`]}),(0,q.jsx)(e,{size:14,className:`input-icon`}),(0,q.jsx)(`input`,{className:`input`,type:`search`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:t===`user`?`Filter by email…`:`Filter by name…`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g.length===1&&(e.preventDefault(),a(g[0].principalId))}})]}),(0,q.jsx)(`div`,{className:`picker-list`,children:s===null?(0,q.jsxs)(`p`,{className:`picker-empty`,children:[(0,q.jsx)(T,{size:13}),`Loading `,f,`s…`]}):m.length===0?(0,q.jsxs)(`p`,{className:`picker-empty`,children:[`No `,f,`s are registered yet.`,` `,(0,q.jsx)(x,{to:t===`user`?`/users`:`/tokens`,children:`Add one`}),` first.`]}):g.length===0?(0,q.jsxs)(`p`,{className:`picker-empty`,children:[`No registered `,f,` matches “`,l.trim(),`”.`]}):g.map(e=>{let n=r.filter(n=>n.principalType===t&&n.principalId===e.principalId).map(B),o=e.principalId===i;return(0,q.jsxs)(`label`,{className:`picker-option${o?` is-chosen`:``}`,children:[(0,q.jsx)(`input`,{type:`radio`,className:`visually-hidden`,name:d,value:e.principalId,checked:o,onChange:()=>a(e.principalId)}),(0,q.jsx)(L,{type:t,id:e.principalId}),(0,q.jsx)(`span`,{className:`picker-name`,children:e.principalId}),n.length>0&&(0,q.jsxs)(`span`,{className:`picker-held`,children:[(0,q.jsx)(`span`,{className:`visually-hidden`,children:`holds`}),n.map(e=>(0,q.jsx)(`span`,{className:`tag`,children:e},e))]}),(0,q.jsx)(_,{size:14,className:`picker-check`})]},e.principalId)})})]})}var Y=[{key:`environments`,label:`Environments`,icon:(0,q.jsx)(y,{size:15})},{key:`users`,label:`Users`,icon:(0,q.jsx)(o,{size:15})},{key:`tokens`,label:`Tokens`,icon:(0,q.jsx)(t,{size:15})},{key:`settings`,label:`Settings`,icon:(0,q.jsx)(c,{size:15})}];function X(){let e=W.useLoaderData(),{project:t}=W.useParams(),n=W.useSearch();if(!e.ok)return(0,q.jsx)(p,{icon:(0,q.jsx)(v,{size:18}),label:(0,q.jsx)(`span`,{className:`mono`,children:t}),title:`No project here for you`,actions:(0,q.jsx)(x,{className:`btn`,to:`/projects`,children:`All projects`}),children:e.error??`There is no such project, or you hold no grant on it. The two look the same on purpose: an answer that told them apart would let anyone list project names.`});let{project:r,grants:i,grantsError:a}=e,o=r.permissions.includes(`project.manage`),s=r.permissions.includes(`environment.manage`),c=r.permissions.includes(`grant.manage`),l=Y.filter(({key:e})=>e===`environments`||(e===`users`||e===`tokens`)&&c||e===`settings`&&o),u=l.find(({key:e})=>e===n.tab)?.key??`environments`,f=u===`users`?`user`:`service`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{tile:r.slug,title:r.name,aside:(0,q.jsx)(`span`,{className:`page-title-slug`,children:r.slug}),actions:u===`environments`?s&&(0,q.jsx)($,{project:r.slug}):(u===`users`||u===`tokens`)&&a===null&&(0,q.jsx)(te,{principalType:f,project:r.slug,environments:r.environments,grants:i})}),r.archivedAt!==null&&(0,q.jsx)(`div`,{style:{marginBottom:`1.25rem`},children:(0,q.jsxs)(C,{tone:`bad`,children:[(0,q.jsx)(`strong`,{children:`This project is archived.`}),` Its environments serve no reads, to people or to machines, until it is restored.`]})}),l.length>1&&(0,q.jsx)(`nav`,{className:`tabs`,"aria-label":`Project sections`,children:l.map(({key:e,label:t,icon:n})=>(0,q.jsxs)(x,{to:`/projects/$project`,params:{project:r.slug},search:{tab:e===`environments`?void 0:e},activeOptions:{exact:!0,explicitUndefined:!0},"aria-current":e===u?`page`:void 0,children:[n,t]},e))}),u===`environments`&&(0,q.jsx)(Z,{project:r,canManage:s}),(u===`users`||u===`tokens`)&&(a===null?(0,q.jsx)(ee,{principalType:f,project:r.slug,grants:i.filter(e=>e.principalType===f)}):(0,q.jsx)(C,{tone:`bad`,children:a})),u===`settings`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ne,{project:r}),(0,q.jsx)(re,{project:r})]})]})}function Z({project:e,canManage:t}){let n=e.environments.filter(N).filter(e=>e.details.archivedAt!==null),r=e.environments.filter(e=>e.details===null||e.details.archivedAt===null);return(0,q.jsxs)(q.Fragment,{children:[r.length===0?(0,q.jsx)(`div`,{className:`card`,children:(0,q.jsx)(S,{title:`No environments yet`,children:t?`Add the first with Add environment.`:`Creating environments needs environment.manage on this project.`})}):(0,q.jsx)(`ul`,{className:`env-grid`,"aria-label":`Environments`,children:r.map(n=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Q,{project:e.slug,environment:n,isAdmin:t})},`${e.slug}:${n.slug}`))}),n.length>0&&(0,q.jsxs)(`section`,{"aria-labelledby":`archived-environments`,children:[(0,q.jsx)(`h2`,{className:`section-title`,id:`archived-environments`,children:`Archived`}),(0,q.jsx)(`ul`,{className:`env-grid`,children:n.map(n=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Q,{project:e.slug,environment:n,isAdmin:t})},n.slug))})]})]})}function Q({project:e,environment:t,isAdmin:r}){let[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(t.slug),[d,p]=(0,K.useState)(t.name),m=k(),{pending:h,error:g,setError:_,run:v}=M(),y=t.details,S=y!==null&&y.archivedAt!==null,C=y?.secretCount??null,A=y!==null&&!S&&t.accessible,N=r&&y!==null,P=l===``?null:G(l);return(0,K.useEffect)(()=>{g!==null&&!a&&j.error(g)},[g,a]),(0,q.jsxs)(`div`,{className:`env-card${A?` is-link`:` is-muted`}`,children:[(0,q.jsxs)(`div`,{className:`env-card-text`,children:[A?(0,q.jsx)(x,{className:`env-card-name stretch`,to:`/projects/$project/$environment`,params:{project:e,environment:t.slug},children:t.name}):(0,q.jsx)(`span`,{className:`env-card-name`,children:t.name}),(0,q.jsxs)(`span`,{className:`env-card-meta`,children:[(0,q.jsx)(`span`,{className:`mono`,children:t.slug}),S?(0,q.jsx)(`span`,{className:`tag tag-red`,children:`archived`}):t.accessible?C!==null&&(0,q.jsxs)(`span`,{children:[C,` secret`,C===1?``:`s`]}):(0,q.jsx)(`span`,{className:`tag tag-outline`,children:`no secret access`})]})]}),N&&(0,q.jsxs)(w.Root,{children:[(0,q.jsx)(w.Trigger,{asChild:!0,children:(0,q.jsx)(`button`,{className:`act act-quiet env-card-menu`,"aria-label":`Actions for ${t.slug}`,disabled:h,children:h?(0,q.jsx)(T,{size:14}):(0,q.jsx)(i,{size:16})})}),(0,q.jsx)(w.Portal,{children:(0,q.jsxs)(w.Content,{className:`menu`,sideOffset:6,align:`end`,children:[(0,q.jsxs)(w.Item,{className:`menu-item`,onSelect:()=>{u(t.slug),p(t.name),o(!0)},children:[(0,q.jsx)(n,{size:14}),`Rename`]}),(0,q.jsx)(w.Separator,{className:`menu-sep`}),(0,q.jsxs)(w.Item,{className:`menu-item${S?``:` menu-item-danger`}`,onSelect:()=>c(!0),children:[S?(0,q.jsx)(b,{size:14}):(0,q.jsx)(f,{size:14}),S?`Restore`:`Archive…`]})]})})]}),N&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{open:a,onOpenChange:e=>{o(e),e||_(null)},title:(0,q.jsxs)(q.Fragment,{children:[`Rename`,` `,(0,q.jsxs)(`span`,{className:`mono`,children:[e,`/`,t.slug]})]}),children:(0,q.jsxs)(`form`,{className:`form`,onSubmit:n=>{n.preventDefault(),v(()=>m.environments.update(`${e}/${t.slug}`,{slug:l,name:d}),()=>{o(!1),j.success(`Environment renamed`)})},children:[(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Slug`}),(0,q.jsx)(`input`,{className:`input input-mono`,autoFocus:!0,spellCheck:!1,value:l,"aria-invalid":P!==null,onChange:e=>u(e.target.value)}),(0,q.jsx)(`span`,{className:`hint${P===null?``:` edit-note-error`}`,children:P??`Anything running coffre run ${e}/${t.slug} will need the new path.`})]}),(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Display name`}),(0,q.jsx)(`input`,{className:`input`,value:d,onChange:e=>p(e.target.value)})]}),(0,q.jsx)(E,{error:g}),(0,q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,q.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>o(!1),children:`Cancel`}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:h||l===``||P!==null||d.trim()===``,children:[h&&(0,q.jsx)(T,{}),`Save`]})]})]})}),(0,q.jsx)(D,{open:s,onOpenChange:c,title:(0,q.jsxs)(q.Fragment,{children:[S?`Restore`:`Archive`,` `,(0,q.jsxs)(`span`,{className:`mono`,children:[e,`/`,t.slug]}),`?`]}),body:C===null?(0,q.jsx)(q.Fragment,{children:`This changes whether the environment serves secrets to principals who have access. Values and history remain stored.`}):S?(0,q.jsxs)(q.Fragment,{children:[`The environment starts serving its `,C,` secret`,C===1?``:`s`,` again, to everyone who holds a grant on it.`]}):(0,q.jsxs)(q.Fragment,{children:[`Its `,C,` secret`,C===1?``:`s`,` stop being served, so anything running `,(0,q.jsx)(`code`,{children:`coffre run`}),` against`,` `,(0,q.jsxs)(`span`,{className:`mono`,children:[e,`/`,t.slug]}),` `,`loses them at its next start. Values and history survive, and restoring is one click.`]}),confirmLabel:S?`Restore environment`:`Archive environment`,destructive:!S,onConfirm:()=>v(()=>m.environments.update(`${e}/${t.slug}`,{archived:!S}),()=>j.success(S?`${t.slug} restored`:`${t.slug} archived`))})]})]})}function $({project:e}){let[t,n]=(0,K.useState)(!1),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(``),c=k(),{pending:l,error:u,setError:d,run:f}=M(),p=i===``?null:G(i);function m(){n(!1),d(null)}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>n(!0),children:[(0,q.jsx)(r,{size:14}),`Add environment`]}),(0,q.jsx)(O,{open:t,onOpenChange:e=>e?n(!0):m(),title:(0,q.jsxs)(q.Fragment,{children:[`New environment in `,(0,q.jsx)(`span`,{className:`mono`,children:e})]}),children:(0,q.jsxs)(`form`,{className:`form`,onSubmit:t=>{t.preventDefault(),f(async()=>{let{created:t}=await c.environments.create(`${e}/${i}`,{name:o});if(!t)throw new A(`An environment named "${i}" already exists.`)},()=>{j.success(`Environment ${i} added`),a(``),s(``),m()})},children:[(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Slug`}),(0,q.jsx)(`input`,{className:`input input-mono`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:`staging`,value:i,"aria-invalid":p!==null,onChange:e=>a(e.target.value)}),(0,q.jsx)(`span`,{className:`hint${p===null?``:` edit-note-error`}`,children:p??(0,q.jsxs)(q.Fragment,{children:[`The CLI will address it as`,` `,(0,q.jsxs)(`span`,{className:`mono`,children:[e,`/`,i===``?`staging`:i]}),`.`]})})]}),(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Display name`}),(0,q.jsx)(`input`,{className:`input`,placeholder:`Staging`,value:o,onChange:e=>s(e.target.value)})]}),(0,q.jsx)(E,{error:u}),(0,q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,q.jsx)(`button`,{className:`btn`,type:`button`,onClick:m,children:`Cancel`}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:l||i===``||p!==null||o.trim()===``,children:[l&&(0,q.jsx)(T,{}),`Add environment`]})]})]})})]})}function ee({principalType:e,project:n,grants:r}){let i=e===`user`;return(0,q.jsx)(`section`,{className:`card`,"aria-label":i?`Users with access`:`Tokens with access`,children:r.length===0?(0,q.jsxs)(S,{title:i?`No user has access`:`No token has access`,children:[`Add `,i?`a user`:`a token`,` with permissions on the whole project or on one environment.`]}):(0,q.jsx)(z,{lead:(0,q.jsxs)(`span`,{className:`th`,children:[i?(0,q.jsx)(l,{size:14}):(0,q.jsx)(t,{size:14}),i?`Email`:`Name`]}),children:r.map((e,t)=>(0,q.jsx)(U,{number:t+1,project:n,grant:e,leadLabel:i?`Email`:`Name`,lead:(0,q.jsx)(P,{type:e.principalType,id:e.principalId})},e.id))})})}function te({principalType:e,project:t,environments:n,grants:i}){let{capabilities:a}=g({from:`__root__`}),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(`viewer:`),[f,p]=(0,K.useState)(``),m=k(),{pending:h,error:_,setError:v,run:y}=M(),b=H(n),x=e===`user`?`user`:`token`;function S(){s(!1),v(null)}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>s(!0),children:[(0,q.jsx)(r,{size:14}),`Add `,x]}),(0,q.jsx)(O,{open:o,onOpenChange:e=>e?s(!0):S(),title:(0,q.jsxs)(q.Fragment,{children:[`Give a `,x,` access to `,(0,q.jsx)(`span`,{className:`mono`,children:t})]}),wide:!0,description:`Owners manage the whole project and its access. Read and write can cover every environment, or one.`,children:(0,q.jsxs)(`form`,{className:`form`,onSubmit:n=>{n.preventDefault();let r=R(u);y(()=>V(m,{project:t,principalType:e,principalId:c.trim(),role:r.role,environmentSlug:r.environmentSlug,expiresAt:f===``?null:new Date(`${f}T23:59:59Z`).toISOString()}),({existed:e})=>{let t=b.find(e=>e.value===u)?.label??`access`;j.success(e?`${c} already has ${t}`:`${c} granted ${t.toLowerCase()}`),l(``),p(``),d(`viewer:`),S()})},children:[(0,q.jsx)(J,{principalType:e,canList:a.canManageGrants,grants:i,value:c,onChange:l}),(0,q.jsxs)(`div`,{className:`form-row`,children:[(0,q.jsxs)(`label`,{className:`field`,style:{flexGrow:2},children:[(0,q.jsx)(`span`,{className:`label`,children:`Permissions`}),(0,q.jsx)(`select`,{className:`select`,value:u,onChange:e=>d(e.target.value),children:b.map(e=>(0,q.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsxs)(`span`,{className:`label`,children:[`Expires `,(0,q.jsx)(`span`,{className:`hint`,children:`(optional)`})]}),(0,q.jsx)(`input`,{className:`input`,type:`date`,value:f,onChange:e=>p(e.target.value)})]})]}),(0,q.jsx)(E,{error:_}),(0,q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,q.jsx)(`button`,{className:`btn`,type:`button`,onClick:S,children:`Cancel`}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:h||c.trim()===``,children:[h&&(0,q.jsx)(T,{}),`Grant access`]})]})]})})]})}function ne({project:e}){let t=m(),[n,r]=(0,K.useState)(e.slug),[i,a]=(0,K.useState)(e.name),o=k(),{pending:s,error:c,run:l}=M(),u=n===``?null:G(n),d=n!==e.slug||i.trim()!==e.name;return(0,K.useEffect)(()=>{r(e.slug),a(e.name)},[e.slug,e.name]),(0,q.jsxs)(`section`,{className:`card`,"aria-labelledby":`general-settings`,children:[(0,q.jsx)(`div`,{className:`card-head`,children:(0,q.jsx)(`div`,{children:(0,q.jsx)(`h2`,{className:`card-title`,id:`general-settings`,children:`General`})})}),(0,q.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),l(()=>o.projects.update(e.slug,{slug:n,name:i}),async()=>{j.success(`Project renamed`),n!==e.slug&&await t.navigate({to:`/projects/$project`,params:{project:n},search:{tab:`settings`}})})},children:[(0,q.jsxs)(`div`,{className:`card-body form-row`,children:[(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Slug`}),(0,q.jsx)(`input`,{className:`input input-mono`,spellCheck:!1,value:n,"aria-invalid":u!==null,onChange:e=>r(e.target.value)}),(0,q.jsx)(`span`,{className:`hint${u===null?``:` edit-note-error`}`,children:u??`Scripts that name the old slug will need the new one.`})]}),(0,q.jsxs)(`label`,{className:`field`,children:[(0,q.jsx)(`span`,{className:`label`,children:`Display name`}),(0,q.jsx)(`input`,{className:`input`,value:i,onChange:e=>a(e.target.value)})]})]}),(0,q.jsxs)(`div`,{className:`card-foot`,children:[c!==null&&(0,q.jsx)(`span`,{className:`hint`,children:(0,q.jsx)(E,{error:c})}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:!d||s||n===``||u!==null||i.trim()===``,children:[s&&(0,q.jsx)(T,{}),`Save`]})]})]})]})}function re({project:e}){let[t,n]=(0,K.useState)(!1),r=k(),{pending:i,error:a,run:o}=M(),s=e.archivedAt!==null;return(0,q.jsxs)(h,{labelledBy:`danger-zone`,title:`Danger zone`,tone:`danger`,children:[(0,q.jsxs)(`div`,{className:`card-row`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`card-row-title`,children:s?`Restore project`:`Archive project`}),(0,q.jsx)(`p`,{className:`card-row-desc`,children:s?`The project reappears in listings and its environments serve reads again, for everyone who holds a grant on it.`:`Every environment stops serving reads, including to machine callers already running. Nothing is deleted, and you can restore it here at any time.`}),a!==null&&(0,q.jsx)(`div`,{style:{marginTop:`0.5rem`},children:(0,q.jsx)(E,{error:a})})]}),(0,q.jsxs)(`button`,{className:`btn ${s?``:`btn-danger-outline`}`,onClick:()=>n(!0),disabled:i,children:[i?(0,q.jsx)(T,{}):s?(0,q.jsx)(b,{size:14}):(0,q.jsx)(f,{size:14}),s?`Restore project`:`Archive project…`]})]}),(0,q.jsx)(D,{open:t,onOpenChange:n,title:(0,q.jsxs)(q.Fragment,{children:[s?`Restore`:`Archive`,` `,(0,q.jsx)(`span`,{className:`mono`,children:e.slug}),`?`]}),body:s?(0,q.jsx)(q.Fragment,{children:`The project reappears in listings and its environments start serving reads again, for everyone who holds a grant on it.`}):(0,q.jsxs)(q.Fragment,{children:[`Every environment in `,(0,q.jsx)(`span`,{className:`mono`,children:e.slug}),` stops serving reads, including to machine callers already running. Nothing is deleted: values, versions and the audit trail over them stay intact, and you can restore it here at any time.`]}),confirmLabel:s?`Restore project`:`Archive project`,destructive:!s,onConfirm:()=>o(()=>r.projects.update(e.slug,{archived:!s}),()=>j.success(s?`${e.slug} restored`:`${e.slug} archived`))})]})}export{X as component};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/projects.index-9RVSbXjb.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/preload-helper-DduCCcmc.js","_coffre/assets/coffre-B0SRYkyG.js","_coffre/assets/use-action-LiHC8kKH.js","_coffre/assets/affordances-CmoY-8Xf.js","_coffre/assets/project-environments-CfIH5kFM.js","_coffre/assets/validation-9Cl_XS-l.js"])))=>i.map(i=>d[i]);
2
- import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{o as r}from"./coffre-B0SRYkyG.js";import{s as i}from"./affordances-CmoY-8Xf.js";import{n as a}from"./project-environments-CfIH5kFM.js";var o=e(`/projects/`)({loader:async({context:{client:e}})=>{let t=await r(async()=>{let[t,{projects:n}]=await Promise.all([e.me(),e.projects.list()]);return{projects:n,capabilities:i(t,n)}});return{result:t,secrets:t.ok?await s(e,t.projects):{}}},component:n(()=>t(()=>import(`./projects.index-9RVSbXjb.js`),__vite__mapDeps([0,1,2,3,4,5,6,7])),`component`)});async function s(e,t){let n=await Promise.all(t.filter(e=>e.archivedAt===null).map(async t=>{let n=t.environments.filter(a);if(n.length===0)return[t.slug,null];let i=await Promise.all(n.map(n=>r(()=>e.secrets.list(`${t.slug}/${n.slug}`)))),o=new Set;for(let e of i){if(!e.ok)return[t.slug,null];for(let t of e.keys)t.archived||o.add(t.key)}return[t.slug,o.size]}));return Object.fromEntries(n)}export{o as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/projects.index-N_kCFBMq.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/preload-helper-DduCCcmc.js","_coffre/assets/coffre-CXkp3Efg.js","_coffre/assets/use-action-CUvWPRTx.js","_coffre/assets/affordances-CmoY-8Xf.js","_coffre/assets/project-environments-CfIH5kFM.js","_coffre/assets/validation-9Cl_XS-l.js"])))=>i.map(i=>d[i]);
2
+ import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{o as r}from"./coffre-CXkp3Efg.js";import{s as i}from"./affordances-CmoY-8Xf.js";import{n as a}from"./project-environments-CfIH5kFM.js";var o=e(`/projects/`)({loader:async({context:{client:e}})=>{let t=await r(async()=>{let[t,{projects:n}]=await Promise.all([e.me(),e.projects.list()]);return{projects:n,capabilities:i(t,n)}});return{result:t,secrets:t.ok?await s(e,t.projects):{}}},component:n(()=>t(()=>import(`./projects.index-N_kCFBMq.js`),__vite__mapDeps([0,1,2,3,4,5,6,7])),`component`)});async function s(e,t){let n=await Promise.all(t.filter(e=>e.archivedAt===null).map(async t=>{let n=t.environments.filter(a);if(n.length===0)return[t.slug,null];let i=await Promise.all(n.map(n=>r(()=>e.secrets.list(`${t.slug}/${n.slug}`)))),o=new Set;for(let e of i){if(!e.ok)return[t.slug,null];for(let t of e.keys)t.archived||o.add(t.key)}return[t.slug,o.size]}));return Object.fromEntries(n)}export{o as t};
@@ -1 +1 @@
1
- import{L as e,Ot as t,Tt as n,a as r,b as i,c as a,ct as o,i as s,n as c,v as l,w as u}from"./page-DbSS7pYH.js";import{D as d,a as f,l as p,o as m,s as h}from"./preload-helper-DduCCcmc.js";import{s as g,t as _}from"./coffre-B0SRYkyG.js";import{r as v,t as y}from"./use-action-LiHC8kKH.js";import{n as b,r as x}from"./affordances-CmoY-8Xf.js";import{n as S}from"./project-environments-CfIH5kFM.js";import{t as C}from"./projects.index-DHIeFVLP.js";import{n as w}from"./validation-9Cl_XS-l.js";var T=t(n()),E=o();function D(){let{result:e,secrets:t}=C.useLoaderData();if(!e.ok)return(0,E.jsx)(c,{icon:(0,E.jsx)(a,{size:18}),title:`Projects could not be listed`,actions:(0,E.jsx)(d,{className:`btn`,to:`/login`,children:`Sign in again`}),children:e.error});let n=e.projects.filter(e=>e.archivedAt===null),r=e.projects.filter(e=>e.archivedAt!==null);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(s,{title:`Projects`,actions:(0,E.jsx)(x,{capabilities:e.capabilities,children:(0,E.jsx)(A,{})})}),n.length===0?(0,E.jsx)(`div`,{className:`card`,children:(0,E.jsx)(f,{title:`Nothing here for you yet`,children:(0,E.jsx)(b,{capabilities:e.capabilities,hasArchivedProjects:r.length>0})})}):(0,E.jsx)(`section`,{className:`card`,"aria-label":`Projects`,children:(0,E.jsx)(O,{projects:n,secrets:t})}),r.length>0&&(0,E.jsxs)(`section`,{"aria-labelledby":`archived-projects`,children:[(0,E.jsx)(`h2`,{className:`section-title`,id:`archived-projects`,children:`Archived`}),(0,E.jsx)(`div`,{className:`card`,children:(0,E.jsx)(O,{projects:r,secrets:t})})]})]})}function O({projects:e,secrets:t}){return(0,E.jsx)(`div`,{className:`dt-wrap`,children:(0,E.jsxs)(`table`,{className:`dt projects stacks`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`n`,children:`#`}),(0,E.jsx)(`th`,{className:`col-project`,children:(0,E.jsxs)(`span`,{className:`th`,children:[(0,E.jsx)(l,{size:14}),`Project`]})}),(0,E.jsx)(`th`,{children:(0,E.jsxs)(`span`,{className:`th`,children:[(0,E.jsx)(u,{size:14}),`Environments`]})}),(0,E.jsx)(`th`,{className:`col-shrink col-secrets`,children:(0,E.jsxs)(`span`,{className:`th`,children:[(0,E.jsx)(i,{size:14}),`Secrets`]})})]})}),(0,E.jsx)(`tbody`,{children:e.map((e,n)=>(0,E.jsx)(k,{number:n+1,project:e,secrets:t[e.slug]??null},e.slug))})]})})}function k({number:e,project:t,secrets:n}){let i=t.archivedAt!==null,a=t.environments.filter(e=>e.details===null||e.details.archivedAt===null);return(0,E.jsxs)(`tr`,{className:`row-link`,children:[(0,E.jsx)(`td`,{className:`n`,children:e}),(0,E.jsx)(`td`,{className:`col-project`,children:(0,E.jsxs)(`span`,{className:`cell-project`,children:[(0,E.jsx)(r,{name:t.slug}),(0,E.jsxs)(`span`,{className:`cell-stack`,children:[(0,E.jsx)(d,{className:`cell-link stretch`,to:`/projects/$project`,params:{project:t.slug},children:t.name}),(0,E.jsx)(`small`,{className:`mono`,children:t.slug})]})]})}),(0,E.jsx)(`td`,{className:`col-envs`,"data-label":`Environments`,children:i||a.length===0?(0,E.jsx)(`span`,{className:`cell-muted`,children:a.length===0?`No environments yet`:`${a.length} environment${a.length===1?``:`s`}`}):(0,E.jsx)(`span`,{className:`env-links`,"aria-label":`Environments in ${t.slug}`,children:a.map(e=>S(e)?(0,E.jsxs)(d,{className:`env-link`,to:`/projects/$project/$environment`,params:{project:t.slug,environment:e.slug},children:[e.slug,(0,E.jsx)(`span`,{className:`count`,children:e.details.secretCount})]},e.slug):(0,E.jsx)(`span`,{className:`env-link`,title:`You can see this environment exists, but not open it`,children:e.slug},e.slug))})}),(0,E.jsx)(`td`,{className:`col-secrets num nowrap`,children:n!==null&&!i?(0,E.jsxs)(E.Fragment,{children:[n,(0,E.jsxs)(`span`,{className:`narrow-only`,children:[` secret`,n===1?``:`s`]})]}):(0,E.jsx)(`span`,{className:`cell-muted wide-only`,children:`—`})})]})}function A(){let[t,n]=(0,T.useState)(``),[r,i]=(0,T.useState)(``),[a,o]=(0,T.useState)(!1),s=g(),{pending:c,error:l,setError:u,run:d}=y(),f=t===``?null:w(t);function b(){o(!1),u(null)}return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>o(!0),children:[(0,E.jsx)(e,{size:14}),`New project`]}),(0,E.jsx)(h,{open:a,onOpenChange:e=>e?o(!0):b(),title:`New project`,description:`A project holds environments, and access is granted on it or on one of its environments. You become its owner.`,children:(0,E.jsxs)(`form`,{className:`form`,onSubmit:e=>{e.preventDefault(),d(async()=>{let{created:e}=await s.projects.create(t,{name:r});if(!e)throw new _(`A project named "${t}" already exists.`)},()=>{v.success(`Project ${t} created`),n(``),i(``),o(!1)})},children:[(0,E.jsxs)(`label`,{className:`field`,children:[(0,E.jsx)(`span`,{className:`label`,children:`Slug`}),(0,E.jsx)(`input`,{className:`input input-mono`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:`market`,value:t,"aria-invalid":f!==null,"aria-describedby":`new-project-slug-hint`,onChange:e=>n(e.target.value)}),(0,E.jsx)(`span`,{className:`hint${f===null?``:` edit-note-error`}`,id:`new-project-slug-hint`,children:f??`Used in paths, as in market/prod. Renaming it later is safe.`})]}),(0,E.jsxs)(`label`,{className:`field`,children:[(0,E.jsx)(`span`,{className:`label`,children:`Display name`}),(0,E.jsx)(`input`,{className:`input`,placeholder:`Market data platform`,value:r,onChange:e=>i(e.target.value)})]}),(0,E.jsx)(m,{error:l}),(0,E.jsxs)(`div`,{className:`dialog-actions`,children:[(0,E.jsx)(`button`,{className:`btn`,type:`button`,onClick:b,children:`Cancel`}),(0,E.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:c||t===``||f!==null||r.trim()===``,children:[c&&(0,E.jsx)(p,{}),`Create project`]})]})]})})]})}export{D as component};
1
+ import{L as e,Ot as t,Tt as n,a as r,b as i,c as a,ct as o,i as s,n as c,v as l,w as u}from"./page-DbSS7pYH.js";import{D as d,a as f,l as p,o as m,s as h}from"./preload-helper-DduCCcmc.js";import{s as g,t as _}from"./coffre-CXkp3Efg.js";import{r as v,t as y}from"./use-action-CUvWPRTx.js";import{n as b,r as x}from"./affordances-CmoY-8Xf.js";import{n as S}from"./project-environments-CfIH5kFM.js";import{t as C}from"./projects.index-BG8W91BX.js";import{n as w}from"./validation-9Cl_XS-l.js";var T=t(n()),E=o();function D(){let{result:e,secrets:t}=C.useLoaderData();if(!e.ok)return(0,E.jsx)(c,{icon:(0,E.jsx)(a,{size:18}),title:`Projects could not be listed`,actions:(0,E.jsx)(d,{className:`btn`,to:`/login`,children:`Sign in again`}),children:e.error});let n=e.projects.filter(e=>e.archivedAt===null),r=e.projects.filter(e=>e.archivedAt!==null);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(s,{title:`Projects`,actions:(0,E.jsx)(x,{capabilities:e.capabilities,children:(0,E.jsx)(A,{})})}),n.length===0?(0,E.jsx)(`div`,{className:`card`,children:(0,E.jsx)(f,{title:`Nothing here for you yet`,children:(0,E.jsx)(b,{capabilities:e.capabilities,hasArchivedProjects:r.length>0})})}):(0,E.jsx)(`section`,{className:`card`,"aria-label":`Projects`,children:(0,E.jsx)(O,{projects:n,secrets:t})}),r.length>0&&(0,E.jsxs)(`section`,{"aria-labelledby":`archived-projects`,children:[(0,E.jsx)(`h2`,{className:`section-title`,id:`archived-projects`,children:`Archived`}),(0,E.jsx)(`div`,{className:`card`,children:(0,E.jsx)(O,{projects:r,secrets:t})})]})]})}function O({projects:e,secrets:t}){return(0,E.jsx)(`div`,{className:`dt-wrap`,children:(0,E.jsxs)(`table`,{className:`dt projects stacks`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`n`,children:`#`}),(0,E.jsx)(`th`,{className:`col-project`,children:(0,E.jsxs)(`span`,{className:`th`,children:[(0,E.jsx)(l,{size:14}),`Project`]})}),(0,E.jsx)(`th`,{children:(0,E.jsxs)(`span`,{className:`th`,children:[(0,E.jsx)(u,{size:14}),`Environments`]})}),(0,E.jsx)(`th`,{className:`col-shrink col-secrets`,children:(0,E.jsxs)(`span`,{className:`th`,children:[(0,E.jsx)(i,{size:14}),`Secrets`]})})]})}),(0,E.jsx)(`tbody`,{children:e.map((e,n)=>(0,E.jsx)(k,{number:n+1,project:e,secrets:t[e.slug]??null},e.slug))})]})})}function k({number:e,project:t,secrets:n}){let i=t.archivedAt!==null,a=t.environments.filter(e=>e.details===null||e.details.archivedAt===null);return(0,E.jsxs)(`tr`,{className:`row-link`,children:[(0,E.jsx)(`td`,{className:`n`,children:e}),(0,E.jsx)(`td`,{className:`col-project`,children:(0,E.jsxs)(`span`,{className:`cell-project`,children:[(0,E.jsx)(r,{name:t.slug}),(0,E.jsxs)(`span`,{className:`cell-stack`,children:[(0,E.jsx)(d,{className:`cell-link stretch`,to:`/projects/$project`,params:{project:t.slug},children:t.name}),(0,E.jsx)(`small`,{className:`mono`,children:t.slug})]})]})}),(0,E.jsx)(`td`,{className:`col-envs`,"data-label":`Environments`,children:i||a.length===0?(0,E.jsx)(`span`,{className:`cell-muted`,children:a.length===0?`No environments yet`:`${a.length} environment${a.length===1?``:`s`}`}):(0,E.jsx)(`span`,{className:`env-links`,"aria-label":`Environments in ${t.slug}`,children:a.map(e=>S(e)?(0,E.jsxs)(d,{className:`env-link`,to:`/projects/$project/$environment`,params:{project:t.slug,environment:e.slug},children:[e.slug,(0,E.jsx)(`span`,{className:`count`,children:e.details.secretCount})]},e.slug):(0,E.jsx)(`span`,{className:`env-link`,title:`You can see this environment exists, but not open it`,children:e.slug},e.slug))})}),(0,E.jsx)(`td`,{className:`col-secrets num nowrap`,children:n!==null&&!i?(0,E.jsxs)(E.Fragment,{children:[n,(0,E.jsxs)(`span`,{className:`narrow-only`,children:[` secret`,n===1?``:`s`]})]}):(0,E.jsx)(`span`,{className:`cell-muted wide-only`,children:`—`})})]})}function A(){let[t,n]=(0,T.useState)(``),[r,i]=(0,T.useState)(``),[a,o]=(0,T.useState)(!1),s=g(),{pending:c,error:l,setError:u,run:d}=y(),f=t===``?null:w(t);function b(){o(!1),u(null)}return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{className:`btn btn-primary`,onClick:()=>o(!0),children:[(0,E.jsx)(e,{size:14}),`New project`]}),(0,E.jsx)(h,{open:a,onOpenChange:e=>e?o(!0):b(),title:`New project`,description:`A project holds environments, and access is granted on it or on one of its environments. You become its owner.`,children:(0,E.jsxs)(`form`,{className:`form`,onSubmit:e=>{e.preventDefault(),d(async()=>{let{created:e}=await s.projects.create(t,{name:r});if(!e)throw new _(`A project named "${t}" already exists.`)},()=>{v.success(`Project ${t} created`),n(``),i(``),o(!1)})},children:[(0,E.jsxs)(`label`,{className:`field`,children:[(0,E.jsx)(`span`,{className:`label`,children:`Slug`}),(0,E.jsx)(`input`,{className:`input input-mono`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:`market`,value:t,"aria-invalid":f!==null,"aria-describedby":`new-project-slug-hint`,onChange:e=>n(e.target.value)}),(0,E.jsx)(`span`,{className:`hint${f===null?``:` edit-note-error`}`,id:`new-project-slug-hint`,children:f??`Used in paths, as in market/prod. Renaming it later is safe.`})]}),(0,E.jsxs)(`label`,{className:`field`,children:[(0,E.jsx)(`span`,{className:`label`,children:`Display name`}),(0,E.jsx)(`input`,{className:`input`,placeholder:`Market data platform`,value:r,onChange:e=>i(e.target.value)})]}),(0,E.jsx)(m,{error:l}),(0,E.jsxs)(`div`,{className:`dialog-actions`,children:[(0,E.jsx)(`button`,{className:`btn`,type:`button`,onClick:b,children:`Cancel`}),(0,E.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:c||t===``||f!==null||r.trim()===``,children:[c&&(0,E.jsx)(p,{}),`Create project`]})]})]})})]})}export{D as component};
@@ -1 +1 @@
1
- import{ct as e,i as t,r as n,t as r}from"./page-DbSS7pYH.js";import{D as i}from"./preload-helper-DduCCcmc.js";import{t as a}from"./settings-BHtK75j4.js";var o=e(),s=new Intl.ListFormat(`en`,{type:`disjunction`});function c(){let{auth:e,directory:c}=a.useLoaderData(),l=e?.signin?.providers.map(e=>e.label)??[],u=c?.ok===!0?c.principals:null,d=u?.filter(e=>e.isRootAdmin)??[],f=u?.filter(e=>e.principalType===`user`).length??0,p=u?.filter(e=>e.principalType===`service`).length??0;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t,{title:`Settings`}),(0,o.jsx)(r,{labelledBy:`instance`,title:`Instance`,description:`Set in the deployment's configuration, so shown here rather than edited.`,children:(0,o.jsxs)(`dl`,{className:`facts`,children:[(0,o.jsx)(n,{label:`Sign-in`,children:e?.signin?`coffre’s own sign-in, with ${s.format(l)}. Only invited members get in.`:`Cloudflare Access. coffre has no sign-in of its own; every request carries an Access assertion that is verified at the origin.`}),u!==null&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n,{label:`Root admins`,children:(0,o.jsx)(`span`,{className:`fact-list`,children:d.map(e=>(0,o.jsx)(`span`,{className:`mono`,children:e.principalId},e.principalId))})}),(0,o.jsx)(n,{label:`Directory`,children:(0,o.jsxs)(`span`,{children:[(0,o.jsxs)(i,{to:`/users`,children:[f,` user`,f===1?``:`s`]}),` · `,(0,o.jsxs)(i,{to:`/tokens`,children:[p,` token`,p===1?``:`s`]})]})})]})]})})]})}export{c as component};
1
+ import{ct as e,i as t,r as n,t as r}from"./page-DbSS7pYH.js";import{D as i}from"./preload-helper-DduCCcmc.js";import{t as a}from"./settings-EimGqlQL.js";var o=e(),s=new Intl.ListFormat(`en`,{type:`disjunction`});function c(){let{auth:e,directory:c}=a.useLoaderData(),l=e?.signin?.providers.map(e=>e.label)??[],u=c?.ok===!0?c.principals:null,d=u?.filter(e=>e.isRootAdmin)??[],f=u?.filter(e=>e.principalType===`user`).length??0,p=u?.filter(e=>e.principalType===`service`).length??0;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t,{title:`Settings`}),(0,o.jsx)(r,{labelledBy:`instance`,title:`Instance`,description:`Set in the deployment's configuration, so shown here rather than edited.`,children:(0,o.jsxs)(`dl`,{className:`facts`,children:[(0,o.jsx)(n,{label:`Sign-in`,children:e?.signin?`coffre’s own sign-in, with ${s.format(l)}. Only invited members get in.`:`Cloudflare Access. coffre has no sign-in of its own; every request carries an Access assertion that is verified at the origin.`}),u!==null&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n,{label:`Root admins`,children:(0,o.jsx)(`span`,{className:`fact-list`,children:d.map(e=>(0,o.jsx)(`span`,{className:`mono`,children:e.principalId},e.principalId))})}),(0,o.jsx)(n,{label:`Directory`,children:(0,o.jsxs)(`span`,{children:[(0,o.jsxs)(i,{to:`/users`,children:[f,` user`,f===1?``:`s`]}),` · `,(0,o.jsxs)(i,{to:`/tokens`,children:[p,` token`,p===1?``:`s`]})]})})]})]})})]})}export{c as component};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/settings-DYc9gBwr.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/preload-helper-DduCCcmc.js"])))=>i.map(i=>d[i]);
2
- import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{o as r}from"./directory--9Q70fmm.js";var i=e(`/settings`)({loader:async({context:{client:e},parentMatchPromise:t})=>{let n=(await t).loaderData,i=n?.capabilities.canManageGrants??!1;return{auth:n?.auth,directory:i?await r(e,!0):null}},component:n(()=>t(()=>import(`./settings-DYc9gBwr.js`),__vite__mapDeps([0,1,2])),`component`)});export{i as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/settings-CNIY0--5.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/preload-helper-DduCCcmc.js"])))=>i.map(i=>d[i]);
2
+ import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{o as r}from"./directory-PEjdb8PS.js";var i=e(`/settings`)({loader:async({context:{client:e},parentMatchPromise:t})=>{let n=(await t).loaderData,i=n?.capabilities.canManageGrants??!1;return{auth:n?.auth,directory:i?await r(e,!0):null}},component:n(()=>t(()=>import(`./settings-CNIY0--5.js`),__vite__mapDeps([0,1,2])),`component`)});export{i as t};
@@ -1 +1 @@
1
- import{$ as e,C as t,L as n,Ot as r,Tt as i,ct as a,t as o}from"./page-DbSS7pYH.js";import{a as s,c,i as l,l as u,n as d,o as f,s as p,u as m}from"./preload-helper-DduCCcmc.js";import{r as h,s as g}from"./coffre-B0SRYkyG.js";import{r as _,t as v}from"./use-action-LiHC8kKH.js";import{t as y}from"./principal-page-CaAlOB_1.js";import{t as b}from"./tokens._token-D69aJAyr.js";var x=r(i(),1),S=a(),C=[30,90,180,365];function w({serviceId:n,tokens:r}){let i=g(),{pending:a,error:c,run:l}=v();return(0,S.jsxs)(o,{labelledBy:`service-tokens`,title:`Credentials`,description:`Bearer tokens this service presents to the API. Each is shown once, when it is issued; coffre keeps only a hash.`,actions:(0,S.jsx)(T,{serviceId:n}),children:[c!==null&&(0,S.jsx)(`div`,{className:`card-body`,children:(0,S.jsx)(f,{error:c})}),r.length===0?(0,S.jsx)(s,{title:`No live credentials`,children:`Nothing can act as this service until a token is issued.`}):(0,S.jsx)(`div`,{className:`dt-wrap`,children:(0,S.jsxs)(`table`,{className:`dt`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{children:`Token`}),(0,S.jsx)(`th`,{className:`col-shrink`,children:`Issued (UTC)`}),(0,S.jsx)(`th`,{className:`col-shrink`,children:`Last used`}),(0,S.jsx)(`th`,{className:`col-shrink`,children:`Expires`}),(0,S.jsx)(`th`,{className:`col-actions`,children:(0,S.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,S.jsx)(`tbody`,{children:r.map(r=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`td`,{children:(0,S.jsxs)(`span`,{className:`cell-account`,children:[(0,S.jsx)(t,{size:15}),(0,S.jsxs)(`span`,{className:`cell-stack`,children:[(0,S.jsx)(`span`,{children:r.label??`Unlabelled`}),(0,S.jsx)(`small`,{className:`mono`,children:r.hint})]})]})}),(0,S.jsx)(`td`,{className:`nowrap`,children:(0,S.jsxs)(`span`,{className:`cell-stack`,children:[(0,S.jsx)(m,{iso:r.createdAt}),(0,S.jsxs)(`small`,{children:[`by `,r.createdBy]})]})}),(0,S.jsx)(`td`,{className:`nowrap cell-muted`,children:r.lastUsedAt===null?`Never`:(0,S.jsxs)(`span`,{className:`cell-stack`,children:[(0,S.jsx)(m,{iso:r.lastUsedAt,display:`relative`}),r.lastUsedIp!==null&&(0,S.jsx)(`small`,{className:`mono`,children:r.lastUsedIp})]})}),(0,S.jsx)(`td`,{className:`nowrap cell-muted`,children:(0,S.jsx)(m,{iso:r.expiresAt,display:`relative`})}),(0,S.jsx)(`td`,{className:`col-actions`,children:(0,S.jsx)(d,{trigger:(0,S.jsxs)(`button`,{className:`act`,disabled:a,children:[(0,S.jsx)(e,{size:13}),`Revoke`]}),title:(0,S.jsxs)(S.Fragment,{children:[`Revoke `,(0,S.jsx)(`span`,{className:`mono`,children:r.hint}),`?`]}),body:`Whatever uses it is refused from its next request. Issue a new token first if the service should keep working.`,confirmLabel:`Revoke token`,onConfirm:()=>l(()=>i.tokens.revoke(h(`service`,n),r.id),()=>_.success(`Token revoked`))})})]},r.id))})]})})]})}function T({serviceId:e}){let[t,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(90),[d,_]=(0,x.useState)(null),y=g(),{pending:b,error:w,setError:T,run:E}=v();function D(){r(!1),_(null),a(``),T(null)}return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{className:`btn btn-sm`,onClick:()=>r(!0),children:[(0,S.jsx)(n,{size:14}),`Issue token`]}),(0,S.jsx)(p,{open:t,onOpenChange:e=>e?r(!0):D(),title:d===null?`Issue a token`:`Copy the token now`,children:d===null?(0,S.jsxs)(`form`,{className:`form`,onSubmit:t=>{t.preventDefault(),E(()=>y.tokens.issue(h(`service`,e),{label:i.trim()===``?null:i.trim(),expiresInDays:o}),e=>_(e))},children:[(0,S.jsxs)(`div`,{className:`form-row`,children:[(0,S.jsxs)(`label`,{className:`field`,children:[(0,S.jsx)(`span`,{className:`label`,children:`Label`}),(0,S.jsx)(`input`,{className:`input`,value:i,maxLength:120,placeholder:`GitHub Actions deploy`,onChange:e=>a(e.target.value)})]}),(0,S.jsxs)(`label`,{className:`field`,style:{flex:`0 0 9rem`},children:[(0,S.jsx)(`span`,{className:`label`,children:`Expires after`}),(0,S.jsx)(`select`,{className:`select`,value:o,onChange:e=>s(Number(e.target.value)),children:C.map(e=>(0,S.jsxs)(`option`,{value:e,children:[e,` days`]},e))})]})]}),(0,S.jsx)(f,{error:w}),(0,S.jsxs)(`div`,{className:`dialog-actions`,children:[(0,S.jsx)(`button`,{className:`btn`,type:`button`,onClick:D,children:`Cancel`}),(0,S.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:b,children:[b&&(0,S.jsx)(u,{}),`Issue token`]})]})]}):(0,S.jsxs)(`div`,{className:`form`,children:[(0,S.jsxs)(c,{tone:`info`,children:[`This is the only time the value is shown. Store it where the service reads its configuration, as `,(0,S.jsx)(`span`,{className:`mono`,children:`COFFRE_TOKEN`}),`.`]}),(0,S.jsxs)(`div`,{className:`token-once`,children:[(0,S.jsx)(`code`,{className:`mono`,children:d.token}),(0,S.jsx)(l,{value:d.token,label:`Copy token`})]}),(0,S.jsxs)(`p`,{className:`hint`,children:[`Expires `,(0,S.jsx)(m,{iso:d.expiresAt}),`. Send it as`,` `,(0,S.jsx)(`span`,{className:`mono`,children:`Authorization: Bearer …`})]}),(0,S.jsx)(`div`,{className:`dialog-actions`,children:(0,S.jsx)(`button`,{className:`btn btn-primary`,type:`button`,onClick:D,children:`Done`})})]})})]})}function E(){let{token:e}=b.useParams(),{page:t,credentials:n}=b.useLoaderData(),r=t.report?.ok===!0&&t.report.report?.status===`active`;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(y,{principalType:`service`,principalId:e,data:t}),r&&n?.ok===!0&&(0,S.jsx)(w,{serviceId:e,tokens:n.tokens})]})}export{E as component};
1
+ import{$ as e,C as t,L as n,Ot as r,Tt as i,ct as a,t as o}from"./page-DbSS7pYH.js";import{a as s,c,i as l,l as u,n as d,o as f,s as p,u as m}from"./preload-helper-DduCCcmc.js";import{r as h,s as g}from"./coffre-CXkp3Efg.js";import{r as _,t as v}from"./use-action-CUvWPRTx.js";import{t as y}from"./principal-page-DjH1cUyz.js";import{t as b}from"./tokens._token-Df2R8TF_.js";var x=r(i(),1),S=a(),C=[30,90,180,365];function w({serviceId:n,tokens:r}){let i=g(),{pending:a,error:c,run:l}=v();return(0,S.jsxs)(o,{labelledBy:`service-tokens`,title:`Credentials`,description:`Bearer tokens this service presents to the API. Each is shown once, when it is issued; coffre keeps only a hash.`,actions:(0,S.jsx)(T,{serviceId:n}),children:[c!==null&&(0,S.jsx)(`div`,{className:`card-body`,children:(0,S.jsx)(f,{error:c})}),r.length===0?(0,S.jsx)(s,{title:`No live credentials`,children:`Nothing can act as this service until a token is issued.`}):(0,S.jsx)(`div`,{className:`dt-wrap`,children:(0,S.jsxs)(`table`,{className:`dt`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{children:`Token`}),(0,S.jsx)(`th`,{className:`col-shrink`,children:`Issued (UTC)`}),(0,S.jsx)(`th`,{className:`col-shrink`,children:`Last used`}),(0,S.jsx)(`th`,{className:`col-shrink`,children:`Expires`}),(0,S.jsx)(`th`,{className:`col-actions`,children:(0,S.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,S.jsx)(`tbody`,{children:r.map(r=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`td`,{children:(0,S.jsxs)(`span`,{className:`cell-account`,children:[(0,S.jsx)(t,{size:15}),(0,S.jsxs)(`span`,{className:`cell-stack`,children:[(0,S.jsx)(`span`,{children:r.label??`Unlabelled`}),(0,S.jsx)(`small`,{className:`mono`,children:r.hint})]})]})}),(0,S.jsx)(`td`,{className:`nowrap`,children:(0,S.jsxs)(`span`,{className:`cell-stack`,children:[(0,S.jsx)(m,{iso:r.createdAt}),(0,S.jsxs)(`small`,{children:[`by `,r.createdBy]})]})}),(0,S.jsx)(`td`,{className:`nowrap cell-muted`,children:r.lastUsedAt===null?`Never`:(0,S.jsxs)(`span`,{className:`cell-stack`,children:[(0,S.jsx)(m,{iso:r.lastUsedAt,display:`relative`}),r.lastUsedIp!==null&&(0,S.jsx)(`small`,{className:`mono`,children:r.lastUsedIp})]})}),(0,S.jsx)(`td`,{className:`nowrap cell-muted`,children:(0,S.jsx)(m,{iso:r.expiresAt,display:`relative`})}),(0,S.jsx)(`td`,{className:`col-actions`,children:(0,S.jsx)(d,{trigger:(0,S.jsxs)(`button`,{className:`act`,disabled:a,children:[(0,S.jsx)(e,{size:13}),`Revoke`]}),title:(0,S.jsxs)(S.Fragment,{children:[`Revoke `,(0,S.jsx)(`span`,{className:`mono`,children:r.hint}),`?`]}),body:`Whatever uses it is refused from its next request. Issue a new token first if the service should keep working.`,confirmLabel:`Revoke token`,onConfirm:()=>l(()=>i.tokens.revoke(h(`service`,n),r.id),()=>_.success(`Token revoked`))})})]},r.id))})]})})]})}function T({serviceId:e}){let[t,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(90),[d,_]=(0,x.useState)(null),y=g(),{pending:b,error:w,setError:T,run:E}=v();function D(){r(!1),_(null),a(``),T(null)}return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{className:`btn btn-sm`,onClick:()=>r(!0),children:[(0,S.jsx)(n,{size:14}),`Issue token`]}),(0,S.jsx)(p,{open:t,onOpenChange:e=>e?r(!0):D(),title:d===null?`Issue a token`:`Copy the token now`,children:d===null?(0,S.jsxs)(`form`,{className:`form`,onSubmit:t=>{t.preventDefault(),E(()=>y.tokens.issue(h(`service`,e),{label:i.trim()===``?null:i.trim(),expiresInDays:o}),e=>_(e))},children:[(0,S.jsxs)(`div`,{className:`form-row`,children:[(0,S.jsxs)(`label`,{className:`field`,children:[(0,S.jsx)(`span`,{className:`label`,children:`Label`}),(0,S.jsx)(`input`,{className:`input`,value:i,maxLength:120,placeholder:`GitHub Actions deploy`,onChange:e=>a(e.target.value)})]}),(0,S.jsxs)(`label`,{className:`field`,style:{flex:`0 0 9rem`},children:[(0,S.jsx)(`span`,{className:`label`,children:`Expires after`}),(0,S.jsx)(`select`,{className:`select`,value:o,onChange:e=>s(Number(e.target.value)),children:C.map(e=>(0,S.jsxs)(`option`,{value:e,children:[e,` days`]},e))})]})]}),(0,S.jsx)(f,{error:w}),(0,S.jsxs)(`div`,{className:`dialog-actions`,children:[(0,S.jsx)(`button`,{className:`btn`,type:`button`,onClick:D,children:`Cancel`}),(0,S.jsxs)(`button`,{className:`btn btn-primary`,type:`submit`,disabled:b,children:[b&&(0,S.jsx)(u,{}),`Issue token`]})]})]}):(0,S.jsxs)(`div`,{className:`form`,children:[(0,S.jsxs)(c,{tone:`info`,children:[`This is the only time the value is shown. Store it where the service reads its configuration, as `,(0,S.jsx)(`span`,{className:`mono`,children:`COFFRE_TOKEN`}),`.`]}),(0,S.jsxs)(`div`,{className:`token-once`,children:[(0,S.jsx)(`code`,{className:`mono`,children:d.token}),(0,S.jsx)(l,{value:d.token,label:`Copy token`})]}),(0,S.jsxs)(`p`,{className:`hint`,children:[`Expires `,(0,S.jsx)(m,{iso:d.expiresAt}),`. Send it as`,` `,(0,S.jsx)(`span`,{className:`mono`,children:`Authorization: Bearer …`})]}),(0,S.jsx)(`div`,{className:`dialog-actions`,children:(0,S.jsx)(`button`,{className:`btn btn-primary`,type:`button`,onClick:D,children:`Done`})})]})})]})}function E(){let{token:e}=b.useParams(),{page:t,credentials:n}=b.useLoaderData(),r=t.report?.ok===!0&&t.report.report?.status===`active`;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(y,{principalType:`service`,principalId:e,data:t}),r&&n?.ok===!0&&(0,S.jsx)(w,{serviceId:e,tokens:n.tokens})]})}export{E as component};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/tokens._token-CkU4dCwo.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/preload-helper-DduCCcmc.js","_coffre/assets/coffre-CXkp3Efg.js","_coffre/assets/use-action-CUvWPRTx.js","_coffre/assets/principal-page-DjH1cUyz.js","_coffre/assets/directory-PEjdb8PS.js","_coffre/assets/grants-4mSkXPU4.js","_coffre/assets/offboarding-DQ-56W0H.js"])))=>i.map(i=>d[i]);
2
+ import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{o as r,r as i}from"./coffre-CXkp3Efg.js";import{n as a}from"./principal-page-DjH1cUyz.js";var o=e(`/tokens/$token`)({loader:async({context:{client:e},params:t,parentMatchPromise:n})=>{let o=(await n).loaderData,[s,c]=await Promise.all([a(e,`service`,t.token,o),o?.capabilities.canManageGrants&&o.auth.signin!==null?r(()=>e.tokens.list(i(`service`,t.token))):Promise.resolve(null)]);return{page:s,credentials:c}},component:n(()=>t(()=>import(`./tokens._token-CkU4dCwo.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),`component`)});export{o as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_coffre/assets/tokens.index-DtiWrKVq.js","_coffre/assets/page-DbSS7pYH.js","_coffre/assets/directory-PEjdb8PS.js","_coffre/assets/preload-helper-DduCCcmc.js","_coffre/assets/coffre-CXkp3Efg.js","_coffre/assets/use-action-CUvWPRTx.js","_coffre/assets/offboarding-DQ-56W0H.js"])))=>i.map(i=>d[i]);
2
+ import{T as e,t,w as n}from"./preload-helper-DduCCcmc.js";import{o as r}from"./directory-PEjdb8PS.js";var i=e(`/tokens/`)({loader:async({context:{client:e},parentMatchPromise:t})=>r(e,(await t).loaderData?.capabilities.canManageGrants??!1),component:n(()=>t(()=>import(`./tokens.index-DtiWrKVq.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`component`)});export{i as t};
@@ -1 +1 @@
1
- import{C as e,ct as t,i as n,n as r}from"./page-DbSS7pYH.js";import{n as i,t as a}from"./directory--9Q70fmm.js";import{t as o}from"./tokens.index-T5bax16J.js";import{n as s}from"./offboarding-BmFuQEv1.js";var c=t();function l(){let t=o.useLoaderData();if(!t.ok)return(0,c.jsx)(r,{icon:(0,c.jsx)(e,{size:18}),label:`Tokens`,title:`Tokens are closed to you`,children:t.error});let l=t.principals.filter(e=>e.principalType===`service`);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(n,{title:`Tokens`,actions:(0,c.jsx)(a,{principalType:`service`})}),(0,c.jsx)(i,{principalType:`service`,principals:l,hasRemoved:t.removed.some(e=>e.principalType===`service`)}),(0,c.jsx)(s,{principalType:`service`,removed:t.removed})]})}export{l as component};
1
+ import{C as e,ct as t,i as n,n as r}from"./page-DbSS7pYH.js";import{n as i,t as a}from"./directory-PEjdb8PS.js";import{t as o}from"./tokens.index-CSf5Mlz8.js";import{n as s}from"./offboarding-DQ-56W0H.js";var c=t();function l(){let t=o.useLoaderData();if(!t.ok)return(0,c.jsx)(r,{icon:(0,c.jsx)(e,{size:18}),label:`Tokens`,title:`Tokens are closed to you`,children:t.error});let l=t.principals.filter(e=>e.principalType===`service`);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(n,{title:`Tokens`,actions:(0,c.jsx)(a,{principalType:`service`})}),(0,c.jsx)(i,{principalType:`service`,principals:l,hasRemoved:t.removed.some(e=>e.principalType===`service`)}),(0,c.jsx)(s,{principalType:`service`,removed:t.removed})]})}export{l as component};