@package-broker/ui 2.0.0-rc.2 → 2.0.0-rc.4

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 (194) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/api-types.d.ts +8148 -2725
  3. package/dist/api-types.d.ts.map +1 -1
  4. package/dist/api.d.ts +1 -1
  5. package/dist/api.d.ts.map +1 -1
  6. package/dist/api.js +10 -0
  7. package/dist/api.js.map +1 -1
  8. package/dist/app-path.d.ts +2 -0
  9. package/dist/app-path.d.ts.map +1 -0
  10. package/dist/app-path.js +2 -0
  11. package/dist/app-path.js.map +1 -0
  12. package/dist/app.d.ts +10 -14
  13. package/dist/app.d.ts.map +1 -1
  14. package/dist/app.js +37 -22
  15. package/dist/app.js.map +1 -1
  16. package/dist/assets/access.62e9484517a0.js +1 -0
  17. package/dist/assets/app.45b156168495.css +2 -0
  18. package/dist/assets/app.c064670cdc0d.js +9 -0
  19. package/dist/assets/audit.b7c40b9dc998.js +1 -0
  20. package/dist/assets/chunk.28a4d8aab337.js +1 -0
  21. package/dist/assets/chunk.3fcd6998795a.js +1 -0
  22. package/dist/assets/chunk.51497edc7697.js +4 -0
  23. package/dist/assets/chunk.56d473a1587d.js +1 -0
  24. package/dist/assets/chunk.675b635d9462.js +1 -0
  25. package/dist/assets/chunk.6ea6bdcaa465.js +1 -0
  26. package/dist/assets/chunk.741aec8d1ff9.js +1 -0
  27. package/dist/assets/chunk.815f9a91c741.js +1 -0
  28. package/dist/assets/chunk.8442124f6802.js +1 -0
  29. package/dist/assets/chunk.965b76812604.js +2 -0
  30. package/dist/assets/chunk.a6d755a9789f.js +1 -0
  31. package/dist/assets/chunk.d18497920e4d.js +1 -0
  32. package/dist/assets/chunk.d813fefb410d.js +1 -0
  33. package/dist/assets/chunk.e3b0c44298fc.js +0 -0
  34. package/dist/assets/chunk.f54ea1378c8c.js +1 -0
  35. package/dist/assets/chunk.fd375c54b526.js +1 -0
  36. package/dist/assets/import.e7a1e5834631.js +1 -0
  37. package/dist/assets/index.html +9 -2
  38. package/dist/assets/manifest.json +108 -8
  39. package/dist/assets/notifications.19225fe12044.js +1 -0
  40. package/dist/assets/npm-login.e059678af13d.js +1 -0
  41. package/dist/assets/packages.ab5ab25b1c75.js +2 -0
  42. package/dist/assets/projects.927fe18c785c.js +1 -0
  43. package/dist/assets/setup.8e977608d413.js +1 -0
  44. package/dist/assets/setup.html +3 -3
  45. package/dist/assets/sources.ae50f239f80f.js +1 -0
  46. package/dist/assets/tokens.6b86d8d97e07.js +4 -0
  47. package/dist/auth.d.ts +26 -3
  48. package/dist/auth.d.ts.map +1 -1
  49. package/dist/auth.js +133 -19
  50. package/dist/auth.js.map +1 -1
  51. package/dist/components/product-footer-content.d.ts +21 -0
  52. package/dist/components/product-footer-content.d.ts.map +1 -0
  53. package/dist/components/product-footer-content.js +30 -0
  54. package/dist/components/product-footer-content.js.map +1 -0
  55. package/dist/components/product-footer.d.ts +3 -0
  56. package/dist/components/product-footer.d.ts.map +1 -0
  57. package/dist/components/product-footer.js +6 -0
  58. package/dist/components/product-footer.js.map +1 -0
  59. package/dist/components/ui/status-badge.d.ts +5 -0
  60. package/dist/components/ui/status-badge.d.ts.map +1 -1
  61. package/dist/components/ui/status-badge.js +10 -0
  62. package/dist/components/ui/status-badge.js.map +1 -1
  63. package/dist/manifest.d.ts +32 -0
  64. package/dist/manifest.d.ts.map +1 -1
  65. package/dist/manifest.js +41 -0
  66. package/dist/manifest.js.map +1 -1
  67. package/dist/package-limits.d.ts +3 -0
  68. package/dist/package-limits.d.ts.map +1 -0
  69. package/dist/package-limits.js +3 -0
  70. package/dist/package-limits.js.map +1 -0
  71. package/dist/page-hash.d.ts +1 -1
  72. package/dist/page-hash.d.ts.map +1 -1
  73. package/dist/page-hash.js.map +1 -1
  74. package/dist/page-loader.d.ts +5 -0
  75. package/dist/page-loader.d.ts.map +1 -0
  76. package/dist/page-loader.js +39 -0
  77. package/dist/page-loader.js.map +1 -0
  78. package/dist/pages/access/grant-form.d.ts +48 -0
  79. package/dist/pages/access/grant-form.d.ts.map +1 -0
  80. package/dist/pages/access/grant-form.js +153 -0
  81. package/dist/pages/access/grant-form.js.map +1 -0
  82. package/dist/pages/access/permission-descriptions.d.ts +2 -0
  83. package/dist/pages/access/permission-descriptions.d.ts.map +1 -0
  84. package/dist/pages/access/permission-descriptions.js +36 -0
  85. package/dist/pages/access/permission-descriptions.js.map +1 -0
  86. package/dist/pages/access/role-catalogue.d.ts +22 -0
  87. package/dist/pages/access/role-catalogue.d.ts.map +1 -0
  88. package/dist/pages/access/role-catalogue.js +40 -0
  89. package/dist/pages/access/role-catalogue.js.map +1 -0
  90. package/dist/pages/access.d.ts +6 -0
  91. package/dist/pages/access.d.ts.map +1 -1
  92. package/dist/pages/access.js +66 -31
  93. package/dist/pages/access.js.map +1 -1
  94. package/dist/pages/audit.d.ts.map +1 -1
  95. package/dist/pages/notification-actions.d.ts +41 -0
  96. package/dist/pages/notification-actions.d.ts.map +1 -0
  97. package/dist/pages/notification-actions.js +187 -0
  98. package/dist/pages/notification-actions.js.map +1 -0
  99. package/dist/pages/notification-draft.d.ts +13 -0
  100. package/dist/pages/notification-draft.d.ts.map +1 -0
  101. package/dist/pages/notification-draft.js +75 -0
  102. package/dist/pages/notification-draft.js.map +1 -0
  103. package/dist/pages/notification-form.d.ts +35 -0
  104. package/dist/pages/notification-form.d.ts.map +1 -0
  105. package/dist/pages/notification-form.js +167 -0
  106. package/dist/pages/notification-form.js.map +1 -0
  107. package/dist/pages/notifications-controller.d.ts +41 -0
  108. package/dist/pages/notifications-controller.d.ts.map +1 -0
  109. package/dist/pages/notifications-controller.js +184 -0
  110. package/dist/pages/notifications-controller.js.map +1 -0
  111. package/dist/pages/notifications.d.ts +10 -0
  112. package/dist/pages/notifications.d.ts.map +1 -0
  113. package/dist/pages/notifications.js +301 -0
  114. package/dist/pages/notifications.js.map +1 -0
  115. package/dist/pages/npm-login.d.ts +2 -0
  116. package/dist/pages/npm-login.d.ts.map +1 -0
  117. package/dist/pages/npm-login.js +62 -0
  118. package/dist/pages/npm-login.js.map +1 -0
  119. package/dist/pages/packages/npm-workflow.d.ts +31 -0
  120. package/dist/pages/packages/npm-workflow.d.ts.map +1 -0
  121. package/dist/pages/packages/npm-workflow.js +381 -0
  122. package/dist/pages/packages/npm-workflow.js.map +1 -0
  123. package/dist/pages/packages/package-detail.d.ts +9 -0
  124. package/dist/pages/packages/package-detail.d.ts.map +1 -0
  125. package/dist/pages/packages/package-detail.js +242 -0
  126. package/dist/pages/packages/package-detail.js.map +1 -0
  127. package/dist/pages/packages/source-actions.d.ts +49 -0
  128. package/dist/pages/packages/source-actions.d.ts.map +1 -0
  129. package/dist/pages/packages/source-actions.js +319 -0
  130. package/dist/pages/packages/source-actions.js.map +1 -0
  131. package/dist/pages/packages.d.ts +15 -4
  132. package/dist/pages/packages.d.ts.map +1 -1
  133. package/dist/pages/packages.js +138 -20
  134. package/dist/pages/packages.js.map +1 -1
  135. package/dist/pages/projects/project-form-model.d.ts +25 -0
  136. package/dist/pages/projects/project-form-model.d.ts.map +1 -0
  137. package/dist/pages/projects/project-form-model.js +69 -0
  138. package/dist/pages/projects/project-form-model.js.map +1 -0
  139. package/dist/pages/projects/project-form.d.ts +14 -0
  140. package/dist/pages/projects/project-form.d.ts.map +1 -0
  141. package/dist/pages/projects/project-form.js +91 -0
  142. package/dist/pages/projects/project-form.js.map +1 -0
  143. package/dist/pages/projects.d.ts +3 -2
  144. package/dist/pages/projects.d.ts.map +1 -1
  145. package/dist/pages/projects.js +29 -38
  146. package/dist/pages/projects.js.map +1 -1
  147. package/dist/pages/sources/source-form.d.ts +5 -2
  148. package/dist/pages/sources/source-form.d.ts.map +1 -1
  149. package/dist/pages/sources/source-form.js +39 -27
  150. package/dist/pages/sources/source-form.js.map +1 -1
  151. package/dist/pages/sources/sync-copy.d.ts +5 -0
  152. package/dist/pages/sources/sync-copy.d.ts.map +1 -0
  153. package/dist/pages/sources/sync-copy.js +11 -0
  154. package/dist/pages/sources/sync-copy.js.map +1 -0
  155. package/dist/pages/sources.d.ts +11 -3
  156. package/dist/pages/sources.d.ts.map +1 -1
  157. package/dist/pages/sources.js +103 -25
  158. package/dist/pages/sources.js.map +1 -1
  159. package/dist/pages/tokens/client-config.d.ts +3 -0
  160. package/dist/pages/tokens/client-config.d.ts.map +1 -1
  161. package/dist/pages/tokens/client-config.js +12 -2
  162. package/dist/pages/tokens/client-config.js.map +1 -1
  163. package/dist/pages/tokens/issue-token-form.d.ts +27 -0
  164. package/dist/pages/tokens/issue-token-form.d.ts.map +1 -0
  165. package/dist/pages/tokens/issue-token-form.js +270 -0
  166. package/dist/pages/tokens/issue-token-form.js.map +1 -0
  167. package/dist/pages/tokens/principal-form.d.ts +8 -0
  168. package/dist/pages/tokens/principal-form.d.ts.map +1 -0
  169. package/dist/pages/tokens/principal-form.js +155 -0
  170. package/dist/pages/tokens/principal-form.js.map +1 -0
  171. package/dist/pages/tokens/trusted-publishers-controller.d.ts +42 -0
  172. package/dist/pages/tokens/trusted-publishers-controller.d.ts.map +1 -0
  173. package/dist/pages/tokens/trusted-publishers-controller.js +202 -0
  174. package/dist/pages/tokens/trusted-publishers-controller.js.map +1 -0
  175. package/dist/pages/tokens/trusted-publishers.d.ts +6 -0
  176. package/dist/pages/tokens/trusted-publishers.d.ts.map +1 -0
  177. package/dist/pages/tokens/trusted-publishers.js +116 -0
  178. package/dist/pages/tokens/trusted-publishers.js.map +1 -0
  179. package/dist/pages/tokens.d.ts +100 -6
  180. package/dist/pages/tokens.d.ts.map +1 -1
  181. package/dist/pages/tokens.js +324 -86
  182. package/dist/pages/tokens.js.map +1 -1
  183. package/dist/setup.d.ts +3 -2
  184. package/dist/setup.d.ts.map +1 -1
  185. package/dist/setup.js +70 -10
  186. package/dist/setup.js.map +1 -1
  187. package/dist/token-pending.d.ts +4 -0
  188. package/dist/token-pending.d.ts.map +1 -0
  189. package/dist/token-pending.js +12 -0
  190. package/dist/token-pending.js.map +1 -0
  191. package/package.json +3 -3
  192. package/dist/assets/app.b2abf3c46f6e.js +0 -15
  193. package/dist/assets/app.e8cea8b32d3a.css +0 -2
  194. package/dist/assets/setup.98343039898f.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{a as $e,b as tt,c as at,d as st,e as ge}from"./chunk.51497edc7697.js";import"./chunk.675b635d9462.js";import"./chunk.e3b0c44298fc.js";import{a as et}from"./chunk.28a4d8aab337.js";import{a as ot,b as nt}from"./chunk.56d473a1587d.js";import"./chunk.d18497920e4d.js";import{a as Xe,b as _e}from"./chunk.8442124f6802.js";import"./chunk.a6d755a9789f.js";import{a as oe,b as Je,c as Q}from"./chunk.965b76812604.js";import"./chunk.3fcd6998795a.js";import{a as K}from"./chunk.d813fefb410d.js";import{a as H}from"./chunk.741aec8d1ff9.js";import{A as pe,B as de,C as me,D as Ye,E as ke,F as $,G as Ke,K as Ze,c as U,d as Ce,g as J,j as Re,m as Qe,n as Ge,p as x,u as We,x as ce,y as le,z as ue}from"./chunk.fd375c54b526.js";var T=U(Ce(),1);var p=U(J(),1);function ct(t){return{visibleToNewProjects:t==="available",newProjectAccessMode:t==="request"?"request":"none"}}function lt(t,e,r,i){return t===null?e.includes("org:sources:write"):t===i&&r.includes("project:sources:write")}function rt(t){return{"If-Match":`"r${t}"`}}function ze(t,e,r,i){return t&&!e&&!r&&i==="pending"}function Fe(t){if(!["pending","not_required","approved"].includes(t.approvalState)||t.scanState==="denied")return[];let e=[];return t.approvalState==="pending"&&e.push("approve"),t.holdScan&&t.scanState==="failed"&&e.push("rescan"),(t.approvalState==="pending"||t.holdScan&&(t.approvalState==="not_required"||t.scanState==="failed"))&&e.push("reject"),e}function qt(t,e){return(!e||t.trim().length>0)&&new TextEncoder().encode(t).length<=1e3&&Array.from(t).every(r=>{let i=r.charCodeAt(0);return i>=32&&i!==127||i===9||i===10||i===13})}var it={queued:"Security scan queued",running:"Security scan running",allowed:"Security scan passed",denied:"Security scan refused",failed:"Security scan failed",not_required:"Security scan not required"};function Ve(t){return(0,p.jsx)("div",{className:"[&_button]:min-h-11",children:(0,p.jsx)(We,{children:(0,p.jsx)(ot,{...t})})})}function ut({services:t,project:e}){let[r,i]=(0,T.useState)([]),[a,b]=(0,T.useState)([]),[m,k]=(0,T.useState)([]),[s,N]=(0,T.useState)([]),[h,S]=(0,T.useState)(e?"Project":"Organization"),[v,w]=(0,T.useState)(!0),[l,q]=(0,T.useState)(!1),[f,g]=(0,T.useState)(""),[A,D]=(0,T.useState)({publishes:null,requests:null}),[u,_]=(0,T.useState)(null),[R,B]=(0,T.useState)(""),[G,y]=(0,T.useState)(""),[W,z]=(0,T.useState)(!1),[Z,ne]=(0,T.useState)(!1),[Ee,he]=(0,T.useState)(0),[X,be]=(0,T.useState)({}),ee=(0,T.useRef)(!1),ye=(0,T.useRef)(null),Y=(0,T.useRef)(0);(0,T.useEffect)(()=>{let c=++Y.current;return w(!0),q(!1),N([]),_(null),ne(!1),ee.current=!1,z(!1),(async()=>{let E=e===null?await t.client.request("get","/_pb/me/permissions"):await t.client.request("get","/_pb/projects/{project}/permissions",{params:{project:e}});if(c!==Y.current)return;let O=E.ok?"organization"in E.data&&e===null?E.data.organization:"project"in E.data?E.data.project:[]:[];if(N(O),e!==null){let[M,F]=await Promise.all([t.client.request("get","/_pb/projects/{project}",{params:{project:e}}),O.includes("project:packages:manage")?t.client.request("get","/_pb/projects/{project}/requestable-packages",{params:{project:e},query:{cursor:X.requests}}):null]);if(c!==Y.current)return;S(M.ok?`Project ${M.data.name}`:"Project"),k(F?.ok?F.data.items:[]),D({publishes:null,requests:F?.ok?F.data.next:null}),q(!E.ok||F!==null&&!F.ok)}else if(O.includes("org:packages:read")){let[M,F]=await Promise.all([t.client.request("get","/_pb/publishes",{query:{actionable:"true",cursor:X.publishes}}),t.client.request("get","/_pb/package-access-requests",{query:{state:"pending",cursor:X.requests}})]);if(c!==Y.current)return;i(M.ok?M.data.items:[]),b(F.ok?F.data.items:[]),D({publishes:M.ok?M.data.next:null,requests:F.ok?F.data.next:null}),q(!M.ok||!F.ok)}else q(!E.ok);w(!1)})(),()=>{++Y.current}},[t,e,Ee,X]),(0,T.useEffect)(()=>t.subscribeReplay?.(c=>{(c.path.startsWith("/_pb/publishes/")||c.path.startsWith("/_pb/package-access-requests/")||e&&c.path===`/_pb/projects/${encodeURIComponent(e)}/package-access-requests`)&&(g(c.ok?"Decision saved.":"Decision could not be saved. Reload and review the latest request."),he(E=>E+1))}),[t,e]);let te=c=>{_(c),B(""),y(""),ne(!1)},je=u?.kind==="publish"?s.includes("org:packages:approve"):u?.kind==="access"?s.includes("org:packages:manage"):s.includes("project:packages:manage"),ae=u?.kind!=="request"&&u?.action==="reject";async function qe(){if(!u||ee.current||!ze(je,W,Z,u.kind==="publish"?Fe(u.item).includes(u.action)?"pending":"closed":u.kind==="access"?u.item.state:"pending"))return;if(!qt(R,ae)){y("Enter a reason of at most 1000 UTF-8 bytes."),ye.current?.focus();return}ee.current=!0,z(!0),y("");let c=Y.current,E=R?{reason:R}:{},O=u.kind==="request"?await t.client.request("post","/_pb/projects/{project}/package-access-requests",{params:{project:e},body:{packageId:u.item.id,...E}}):u.kind==="publish"?await t.client.request("post",`/_pb/publishes/{id}/${u.action}`,{params:{id:u.item.id},headers:rt(u.item.revision),body:u.action==="rescan"?{}:E}):await t.client.request("post",`/_pb/package-access-requests/{id}/${u.action}`,{params:{id:u.item.id},headers:rt(u.item.revision),body:E});if(c===Y.current){if(ee.current=!1,z(!1),!O.ok){O.code==="reauth_required"&&t.requireReauth(O.request,{credential:!1,secretFields:[],display:{version:u.kind==="publish"?u.item.version:"",packageName:u.kind==="request"?u.item.name:u.item.packageName,scope:h}}),O.status===409||O.status===412?(ne(!0),y("This request changed. Reload the latest requests before reviewing again.")):y(O.code==="reauth_required"?"Sign in again, then reload and review this decision before submitting.":"The decision could not be saved. Try again.");return}g(u.kind==="request"?"Package access requested. An organization administrator must approve it.":u.kind==="publish"&&u.action==="rescan"?"Security scan queued. The version remains held until all required reviews pass.":`${u.kind==="publish"?"Publish":"Package access"} ${u.action==="approve"?"approved":"rejected"}.${u.kind==="publish"&&u.action==="approve"&&u.item.holdScan?" The package remains held until the security scan passes.":""}`),_(null),he(M=>M+1)}}let re=()=>{_(null),he(c=>c+1)};return v?(0,p.jsx)(Q,{kind:"loading",title:"Loading package requests\u2026"}):l?(0,p.jsx)(Q,{kind:"error",title:"Package requests could not be loaded.",children:(0,p.jsx)(x,{type:"button",className:"min-h-11",onClick:re,children:"Try again"})}):s.includes(e?"project:packages:manage":"org:packages:read")?(0,p.jsxs)("div",{className:"my-6 space-y-6 break-words",children:[(0,p.jsx)("p",{role:"status",children:f}),e?(0,p.jsxs)("section",{"aria-label":"Request package access",children:[(0,p.jsx)("h2",{className:"text-lg font-semibold",children:"Request package access"}),(0,p.jsxs)("p",{children:[h,". Attach the hosted source to this project first. Only packages that allow requests and have an active attached source appear here."]}),(0,p.jsxs)("p",{children:[m.length," ",m.length===1?"requestable package":"requestable packages"," on this page"]}),(0,p.jsx)(oe,{label:"Requestable packages",items:m,columns:[{key:"name",label:"Package",value:c=>c.name},{key:"action",label:"Actions",value:()=>"",render:c=>(0,p.jsx)(Ve,{entityLabel:c.name,actions:[{id:"request",label:"Request access",onSelect:()=>te({kind:"request",item:c})}]})}]}),!m.length&&(0,p.jsx)("p",{children:"No packages available to request on this page."}),A.requests&&(0,p.jsx)(x,{type:"button",className:"min-h-11",onClick:()=>be(c=>({...c,requests:A.requests})),children:"Next requestable packages"})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("section",{"aria-label":"Pending publishes",children:[(0,p.jsx)("h2",{className:"text-lg font-semibold",children:"Pending publishes"}),(0,p.jsxs)("p",{children:[h,". Approval releases a version only after all required security scans pass. Rejection is permanent for this version."]}),(0,p.jsxs)("p",{children:[r.length," ",r.length===1?"held publish":"held publishes"," on this page"]}),(0,p.jsx)(oe,{label:"Pending publishes",items:r,columns:[{key:"package",label:"Package",value:c=>c.packageName,render:c=>(0,p.jsxs)(p.Fragment,{children:[c.packageName,(0,p.jsx)("span",{className:"block font-mono",children:c.version})]})},{key:"context",label:"Source and requester",value:c=>c.sourceName,render:c=>(0,p.jsxs)(p.Fragment,{children:[c.sourceName,(0,p.jsxs)("span",{className:"block",children:[c.requestedBy.name," \xB7 ",c.project?.name??"Organization"]})]})},{key:"scan",label:"Review status",value:c=>it[c.scanState],render:c=>(0,p.jsxs)(p.Fragment,{children:[it[c.scanState],(0,p.jsx)("span",{className:"block",children:c.approvalState==="pending"?"Approval pending":c.approvalState==="approved"?"Publish approved":"Approval not required"})]})},{key:"expires",label:"Expires",value:c=>c.expiresAt,render:c=>(0,p.jsx)(K,{value:c.expiresAt})},{key:"actions",label:"Actions",value:()=>"",render:c=>s.includes("org:packages:approve")?(0,p.jsx)(Ve,{entityLabel:`${c.packageName} ${c.version}`,actions:Fe(c).filter(E=>E!=="reject").map(E=>({id:E,label:E==="rescan"?"Rescan":"Approve publish",onSelect:()=>te({kind:"publish",item:c,action:E})})),overflow:Fe(c).includes("reject")?[{id:"reject",label:c.approvalState==="approved"?"Dispose failed publish":"Reject publish",variant:"destructive",onSelect:()=>te({kind:"publish",item:c,action:"reject"})}]:[]}):null}]}),!r.length&&(0,p.jsx)("p",{children:"No actionable holds on this page."}),A.publishes&&(0,p.jsx)(x,{type:"button",className:"min-h-11",onClick:()=>be(c=>({...c,publishes:A.publishes})),children:"Next publishes"})]}),(0,p.jsxs)("section",{"aria-label":"Access requests",children:[(0,p.jsx)("h2",{className:"text-lg font-semibold",children:"Access requests"}),(0,p.jsxs)("p",{children:[h,". Approval gives the named project access to this package. Other project access remains unchanged."]}),(0,p.jsxs)("p",{children:[a.length," ",a.length===1?"access request":"access requests"," on this page"]}),(0,p.jsx)(oe,{label:"Access requests",items:a,columns:[{key:"package",label:"Package",value:c=>c.packageName},{key:"project",label:"Project",value:c=>c.project.name},{key:"reason",label:"Requester and reason",value:c=>c.requestedBy.name,render:c=>(0,p.jsxs)(p.Fragment,{children:[c.requestedBy.name,(0,p.jsx)("p",{className:"whitespace-pre-wrap",children:c.reason||"No reason provided"})]})},{key:"expires",label:"Expires",value:c=>c.expiresAt,render:c=>(0,p.jsx)(K,{value:c.expiresAt})},{key:"actions",label:"Actions",value:()=>"",render:c=>s.includes("org:packages:manage")?(0,p.jsx)(Ve,{entityLabel:`${c.packageName} for ${c.project.name}`,actions:[{id:"approve",label:"Approve access",onSelect:()=>te({kind:"access",item:c,action:"approve"})}],overflow:[{id:"reject",label:"Reject access",variant:"destructive",onSelect:()=>te({kind:"access",item:c,action:"reject"})}]}):null}]}),!a.length&&(0,p.jsx)("p",{children:"No pending access requests on this page."}),A.requests&&(0,p.jsx)(x,{type:"button",className:"min-h-11",onClick:()=>be(c=>({...c,requests:A.requests})),children:"Next access requests"})]})]}),(0,p.jsx)(x,{type:"button",className:"min-h-11",variant:"outline",onClick:re,children:"Refresh requests"}),(0,p.jsx)(ce,{open:u!==null,onOpenChange:c=>{!c&&!W&&_(null)},children:(0,p.jsxs)(le,{className:"[&_button]:min-h-11 [&_button]:min-w-11",children:[(0,p.jsxs)(ue,{children:[(0,p.jsx)(de,{children:u?.kind==="request"?"Request package access":u?.action==="rescan"?"Rescan publish":u?.action==="reject"?"Reject request":"Approve request"}),(0,p.jsx)(me,{children:u?`${u.kind==="request"?u.item.name:u.item.packageName} \xB7 ${u.kind==="access"?u.item.project.name:h}. ${u.kind==="publish"?"Rejection permanently removes this version. Rescan queues another security review and keeps the version held. Approval still requires all security scans to pass.":"An approved request gives this project access to the package."}`:""})]}),(0,p.jsxs)("form",{noValidate:!0,onSubmit:c=>{c.preventDefault(),qe()},className:"space-y-4","aria-busy":W,children:[!(u?.kind==="publish"&&u.action==="rescan")&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)($,{htmlFor:"package-decision-reason",children:["Reason (",ae?"required":"optional",")"]}),(0,p.jsx)(nt,{id:"package-decision-reason",ref:ye,className:"min-h-24 w-full rounded border p-2",required:ae,value:R,disabled:W,onChange:c=>B(c.target.value),"aria-describedby":"package-reason-help package-decision-error","aria-invalid":!!G}),(0,p.jsx)("p",{id:"package-reason-help",children:"At most 1000 UTF-8 bytes. The reason is recorded with the decision."})]}),(0,p.jsx)("p",{id:"package-decision-error",role:"alert",children:G}),Z&&(0,p.jsx)(x,{type:"button",className:"min-h-11",onClick:re,children:"Reload latest requests"}),(0,p.jsxs)(pe,{children:[(0,p.jsx)(x,{type:"button",className:"min-h-11",variant:"outline",disabled:W,onClick:()=>_(null),children:"Cancel"}),(0,p.jsx)(x,{type:"submit",className:"min-h-11",disabled:W||Z,variant:ae?"destructive":"default",children:W?"Saving decision\u2026":u?.kind==="request"?"Send request":u?.kind==="publish"&&u.action==="rescan"?"Queue rescan":ae?"Confirm rejection":"Confirm approval"})]})]})]})})]}):null}var P=U(Ce(),1);var d=U(J(),1);function St(t,e,r,i){let a=`${r}/${encodeURIComponent(i)}`;return t==="npm"?`registry=${a}/npm/`:`composer config repositories.${i} composer ${a}
2
+ composer require ${e}`}function pt({services:t,id:e,project:r,back:i="#/packages"}){let[a,b]=(0,P.useState)(null),[m,k]=(0,P.useState)(null),[s,N]=(0,P.useState)([]),[h,S]=(0,P.useState)(r??""),[v,w]=(0,P.useState)(""),[l,q]=(0,P.useState)([]),[f,g]=(0,P.useState)([]),[A,D]=(0,P.useState)(null),[u,_]=(0,P.useState)([]),[R,B]=(0,P.useState)(),[G,y]=(0,P.useState)(null),[W,z]=(0,P.useState)(!1),[Z,ne]=(0,P.useState)(null),[Ee,he]=(0,P.useState)(0),X=(0,P.useRef)(null),[be,ee]=(0,P.useState)(!1),[ye,Y]=(0,P.useState)(""),[te,je]=(0,P.useState)(!0),[ae,qe]=(0,P.useState)(!1),[re,c]=(0,P.useState)("unavailable"),[E,O]=(0,P.useState)(!1),[M,F]=(0,P.useState)(!1),[yt,ie]=(0,P.useState)(""),[Te,Se]=(0,P.useState)(0),Ne=(0,P.useRef)(0),we=(0,P.useRef)(!1);(0,P.useEffect)(()=>{let j=!0;return++Ne.current,je(!0),qe(!1),b(null),k(null),q([]),g([]),O(!1),we.current=!1,(async()=>{let[C,He,xe]=await Promise.all([t.client.request("get","/_pb/me/permissions"),r?t.client.request("get","/_pb/projects/{project}/permissions",{params:{project:r}}):null,r?t.client.request("get","/_pb/projects/{project}",{params:{project:r}}):null]),Le=r?await t.client.request("get","/_pb/projects/{project}/packages/{package}",{params:{project:r,package:e}}):await t.client.request("get","/_pb/packages/{package}",{params:{package:e}}),Pe=Le.ok?Le.data:null,Ie=Pe;if(j){if(Le.ok||qe(!0),b(Pe),k(Ie),c(Ie?.visibleToNewProjects?"available":Ie?.newProjectAccessMode==="request"?"request":"unavailable"),F(!1),q(C.ok?C.data.organization:[]),g(He?.ok?He.data.project:[]),D(xe?.ok?xe.data.id:null),w(xe?.ok?xe.data.name:""),!r&&C.ok&&C.data.organization.includes("org:projects:read")){let De=[],Be;do{let se=await t.client.request("get","/_pb/projects",{query:{after:Be}});if(!j)return;if(!se.ok)break;De.push(...se.data.items),Be=se.data.next??void 0}while(Be);if(N(De),Pe?.source.projectId){let se=De.find(Ae=>Ae.id===Pe.source.projectId);if(se){let Ae=await t.client.request("get","/_pb/projects/{project}/permissions",{params:{project:se.slug}});if(!j)return;g(Ae.ok?Ae.data.project:[]),D(se.id)}}}je(!1)}})(),()=>{j=!1,++Ne.current}},[t,e,r,Te]),(0,P.useEffect)(()=>{if(!a)return;let j=!0;return _([]),z(!1),(async()=>{let C=r?await t.client.request("get","/_pb/projects/{project}/packages/{package}/versions",{params:{project:r,package:e},query:{after:R}}):await t.client.request("get","/_pb/packages/{package}/versions",{params:{package:e},query:{after:R}});j&&(_(C.ok?C.data.items:[]),y(C.ok?C.data.next:null),z(!C.ok))})(),()=>{j=!1}},[t,a,e,r,R,Te]),(0,P.useEffect)(()=>{let j=!0;if(ne(null),ee(!1),!h){Y("Choose a project to read the README within its package access.");return}return Y("Loading README\u2026"),t.client.request("get","/_pb/projects/{project}/packages/{package}/readme",{params:{project:h,package:e}}).then(C=>{j&&(ne(C.ok?C.data:null),ee(!C.ok&&(C.status===0||C.status>=500)),Y(C.ok?"README loaded.":C.status===403?"This project cannot read this package.":C.status===404?"No README is available for the active latest version in this project.":C.status===0||C.status>=500?"README could not be loaded. Try again.":"README is unavailable."))}),()=>{j=!1}},[t,e,h,Te,Ee]),(0,P.useEffect)(()=>t.subscribeReplay?.(j=>{j.path===`/_pb/packages/${encodeURIComponent(e)}/access`&&(j.ok?(ie("Access policy saved. Existing project access is unchanged."),Se(C=>C+1)):(F(!0),ie("The policy could not be saved. Reload the latest settings before saving.")))}),[t,e]);let Ue=a&&lt(a.source.projectId,l,f,A);async function jt(){if(!m||we.current||!ze(!!Ue,E,M,"pending"))return;we.current=!0,O(!0),ie("");let j=Ne.current,C=await t.client.request("patch","/_pb/packages/{package}/access",{params:{package:e},body:{...ct(re),revision:m.revision}});if(j===Ne.current){if(we.current=!1,O(!1),!C.ok){C.code==="reauth_required"&&t.requireReauth(C.request,{credential:!1,secretFields:[],display:{version:"",packageName:m.name,scope:r?`Project ${v}`:"Organization"}}),C.status===409?(F(!0),ie("This package changed while you were editing. Reload the latest settings before saving. Your selection is retained for comparison.")):ie(C.code==="reauth_required"?"Sign in again, then reload and review the access policy before saving.":"Access policy could not be saved. Try again.");return}k({...m,...C.data}),ie("Access policy saved. Existing project access is unchanged.")}}return(0,d.jsxs)("section",{"aria-labelledby":"package-detail-heading",className:"min-w-0 space-y-6 break-words",children:[(0,d.jsx)("a",{href:i,className:"inline-flex min-h-11 items-center text-blue-700 underline",children:"Back to packages"}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,d.jsx)("h1",{id:"package-detail-heading",tabIndex:-1,className:"text-2xl font-semibold",children:a?.name??"Package details"}),(0,d.jsx)(x,{type:"button",className:"min-h-11",variant:"outline",onClick:()=>Se(j=>j+1),children:"Reload package"})]}),te?(0,d.jsx)(Q,{kind:"loading",title:"Loading package\u2026"}):ae?(0,d.jsx)(Q,{kind:"error",title:"Package could not be loaded.",children:(0,d.jsx)(x,{type:"button",className:"min-h-11",onClick:()=>Se(j=>j+1),children:"Try again"})}):a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("p",{children:[r?`Project ${v}`:"Organization"," \xB7 Source: ",a.source.name," \xB7"," ",ge[a.source.type]]}),(0,d.jsx)("p",{role:"status",children:yt}),(0,d.jsx)("a",{className:"inline-flex min-h-11 items-center text-blue-700 underline",href:`${i}${i.includes("?")?"&":"?"}package=${e}`,children:"Manage version status"}),m&&Ue&&(0,d.jsxs)("form",{className:"max-w-5xl space-y-4",onSubmit:j=>{j.preventDefault(),jt()},children:[(0,d.jsx)($,{htmlFor:"package-new-access",children:"Access for new projects"}),(0,d.jsxs)(H,{className:"min-h-11",id:"package-new-access",value:re,onChange:j=>c(j.target.value),disabled:E,"aria-describedby":"package-access-help",children:[(0,d.jsx)("option",{value:"available",children:"Available"}),(0,d.jsx)("option",{value:"request",children:"Require approval"}),(0,d.jsx)("option",{value:"unavailable",children:"Not available"})]}),(0,d.jsxs)("p",{id:"package-access-help",children:[a.source.projectId?`Project ${v||s.find(j=>j.id===a.source.projectId)?.name||"Name unavailable"}`:"Organization"," ","\xB7 ",a.name,". Available allows new projects to use this package. Require approval lets project managers request access. Not available prevents new project access. Existing project access is unchanged."]}),(0,d.jsx)(x,{className:"min-h-11",type:"submit",disabled:E||M,children:E?"Saving access policy\u2026":"Save access policy"}),M&&(0,d.jsx)(x,{type:"button",className:"min-h-11",variant:"outline",onClick:()=>Se(j=>j+1),children:"Reload latest settings"})]}),(0,d.jsx)("div",{children:!r&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)($,{htmlFor:"readme-project",children:"Project for README and install instructions"}),(0,d.jsxs)(H,{className:"min-h-11",id:"readme-project",value:h,onChange:j=>S(j.target.value),children:[(0,d.jsx)("option",{value:"",children:"Choose a project"}),s.map(j=>(0,d.jsx)("option",{value:j.slug,children:j.name},j.id))]})]})}),(0,d.jsxs)("section",{children:[(0,d.jsx)("h2",{className:"text-lg font-semibold",children:"Install"}),a.ecosystem==="npm"&&h&&(0,d.jsxs)("p",{children:["Add this line to .npmrc, then run npm install ",a.name,"."]}),h?(0,d.jsx)("pre",{className:"whitespace-pre-wrap break-all rounded border p-4",children:St(a.ecosystem,a.name,window.location.origin,h)}):(0,d.jsx)("p",{children:"Choose a project to see its registry address. Configure project credentials in your package manager."})]}),(0,d.jsxs)("section",{children:[(0,d.jsx)("h2",{className:"text-lg font-semibold",children:"README"}),(0,d.jsx)("p",{ref:X,tabIndex:-1,role:"status",children:ye}),Z&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("p",{children:[Z.filename," \xB7 ",Z.sizeBytes," bytes"]}),(0,d.jsx)("pre",{className:"max-w-full whitespace-pre-wrap break-all rounded border p-4 font-mono text-sm",children:Z.body})]}),be&&(0,d.jsx)(x,{type:"button",className:"min-h-11",variant:"outline",onClick:()=>{X.current?.focus(),he(j=>j+1)},children:"Try again"})]}),(0,d.jsxs)("section",{children:[(0,d.jsx)("h2",{className:"text-lg font-semibold",children:"Versions"}),W?(0,d.jsx)("p",{role:"alert",children:"Versions could not be loaded. Reload the package to try again."}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(Oe,{item:a,versions:u,access:{organization:[],project:[],projectId:null,projectSlug:r},busy:!1,onAction:()=>{}}),u.map(j=>(0,d.jsxs)("details",{className:"my-4 rounded border p-4",children:[(0,d.jsxs)("summary",{className:"min-h-11 cursor-pointer",children:["Publication details for ",j.version]}),(0,d.jsxs)("dl",{children:[(0,d.jsx)("dt",{children:"Integrity"}),(0,d.jsx)("dd",{className:"break-all font-mono",children:j.integrity??"Unavailable"}),(0,d.jsx)("dt",{children:"Distribution tags"}),(0,d.jsx)("dd",{children:j.distTags.join(", ")||"No tags"}),(0,d.jsx)("dt",{children:"Published through the broker"}),(0,d.jsx)("dd",{children:j.publishedBy?.displayName??"Attribution unavailable"}),(0,d.jsx)("dt",{children:"Approved by"}),(0,d.jsx)("dd",{children:j.approvedBy?(0,d.jsxs)(d.Fragment,{children:[j.approvedBy.displayName," \xB7"," ",(0,d.jsx)(K,{value:j.approvedBy.decidedAt})]}):"Not approved"})]})]},j.id)),G&&(0,d.jsx)(x,{type:"button",className:"min-h-11",onClick:()=>B(G),children:"Next versions"})]})]})]}):(0,d.jsx)("p",{children:"Package unavailable in this scope."})]})}var V=U(Ce(),1);var o=U(J(),1);function dt(t){return t.status==="paused"?"Paused \xB7 Enable this source to sync.":t.lastError?"Last check failed":t.lastSuccessAt?"Last check succeeded":"Not checked yet"}function Me(t){return["packagist_proxy","npmjs_proxy","npm_registry"].includes(t.type)&&"attached"in t&&t.attached}function mt(t,e,r,i){return t.projectId===null?e.includes("org:sources:write"):t.projectId===i&&r.includes("project:sources:write")}function Nt(t){return["packagist_proxy","npmjs_proxy","npm_registry"].includes(t.type)?"Checks packages already held from this source when their metadata is due for refresh. This does not download the whole registry.":t.type==="vcs"?"Syncs the Composer package from this configured Git repository.":"Syncs packages selected in this source's settings."}function wt(t,e){let{client:r}=t,i={loading:!0,busy:!1,organization:[],permissions:[],projects:[],project:null,sources:[],error:null,notice:null,requested:[],available:null},a=new Set,b=s=>{i={...i,...s},a.forEach(N=>N())},m=0;async function k(s){let N=++m;if(b({loading:!0,busy:!1,project:null,permissions:[],sources:[],error:null,notice:null,available:null}),s===null){let l=[],q;do{let f=await r.request("get","/_pb/sources",{query:{ownership:"organization",limit:"100",...q?{after:q}:{}}});if(N!==m)return;if(!f.ok){b({loading:!1,error:"Sources could not be loaded. Try again."});return}l.push(...f.data.items),q=f.data.next??void 0}while(q);b({loading:!1,sources:l});return}let[h,S]=await Promise.all([r.request("get","/_pb/projects/{project}",{params:{project:s}}),r.request("get","/_pb/projects/{project}/permissions",{params:{project:s}})]);if(N!==m)return;if(!h.ok||h.data.status!=="active"||!S.ok){b({loading:!1,error:"Project access could not be loaded. Choose an active project."});return}let v=[],w;do{let l=await r.request("get","/_pb/projects/{project}/sources",{params:{project:s},query:{limit:"100",...w?{after:w}:{}}});if(N!==m)return;if(!l.ok){b({loading:!1,error:"Sources could not be loaded. Try again."});return}v.push(...l.data.items.filter(q=>q.attached)),w=l.data.next??void 0}while(w);b({loading:!1,project:h.data,permissions:S.data.project,sources:v})}return{snapshot:()=>i,subscribe:s=>(a.add(s),()=>{a.delete(s)}),selectProject:k,clearFeedback(){b({notice:null,error:null,available:null})},async load(){let s=await r.request("get","/_pb/me/permissions");if(b({organization:s.ok?s.data.organization:[]}),e===null){let N=[],h;do{let S=await r.request("get","/_pb/projects",{query:{status:"active",limit:"100",...h?{after:h}:{}}});if(!S.ok)break;let v=await Promise.all(S.data.items.filter(w=>w.status==="active").map(async w=>{let l=await r.request("get","/_pb/projects/{project}/permissions",{params:{project:w.slug}});return l.ok&&l.data.project.includes("project:sources:write")?w:null}));N.push(...v.filter(w=>w!==null)),h=S.data.next??void 0}while(h);b({projects:N})}await k(e)},async submit(s,N,h){let S=i.sources.find(q=>q.id===N);if(!S||i.busy||i.loading||S.status==="paused"||s==="mirror"&&(!i.project||!i.permissions.includes("project:sources:write")||!Me(S))||s==="sync"&&(!mt(S,i.organization,i.permissions,i.project?.id??null)||i.requested.includes(S.id)))return;if(h=h.trim(),s==="mirror"&&(!h||h.length>428)){b({error:"Enter a package name of 1 to 428 characters."});return}let v=m;b({busy:!0,error:null,notice:null,available:null});let w=s==="mirror"?await r.request("post","/_pb/projects/{project}/sources/{source}/packages",{params:{project:i.project.slug,source:S.id},body:{name:h}}):S.projectId===null?await r.request("post","/_pb/sources/{source}/sync",{params:{source:S.id}}):await r.request("post","/_pb/projects/{project}/sources/{source}/sync",{params:{project:i.project.slug,source:S.id}});if(v!==m)return;let l=s==="sync"?at(w):w;l.ok?b({busy:!1,notice:s==="mirror"?tt(l.status,h,S.name):$e,available:s==="mirror"&&l.status===200?{name:h,source:S.id}:null,requested:s==="sync"?[...i.requested,S.id]:i.requested}):b({busy:!1,error:l.status===403?"You no longer have permission to sync this source. Your selection has been kept.":l.code==="source_paused"?"This source is paused. Enable it before syncing.":l.code==="package_not_found"?`No packages match \u2018${h}\u2019 in ${S.name}. Check the name or choose another source.`:l.status===400?"Enter a valid package name for this source.":"Sync couldn't be queued. Try again shortly."})}}}function xt({ecosystem:t,mirror:e,setup:r,imported:i,onMirror:a,sourceLink:b}){return(0,o.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,o.jsxs)("div",{className:"rounded border p-4",children:[(0,o.jsx)("h3",{className:"font-semibold",children:"From a mirror"}),(0,o.jsx)("p",{children:t==="npm"?"Find packages in a connected npm registry.":"Find packages in Packagist or another connected Composer repository."}),e?(0,o.jsx)(x,{className:"mt-2 min-h-11",onClick:a,children:"From a mirror"}):(0,o.jsx)("p",{children:"A project source manager can add packages from a mirror."})]}),t==="composer"?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"rounded border p-4",children:[(0,o.jsx)("h3",{className:"font-semibold",children:"From a connected GitHub organization"}),(0,o.jsx)("p",{children:"Choose repositories your GitHub connection can access."}),(0,o.jsx)("p",{children:"Organization picker \xB7 Coming soon"}),r?(0,o.jsx)("a",{className:"inline-flex min-h-11 items-center underline",href:`${b}&provider=github`,children:"Set up a GitHub repository source"}):(0,o.jsx)("p",{children:"Ask an organization source manager to connect GitHub."})]}),(0,o.jsxs)("div",{className:"rounded border p-4",children:[(0,o.jsx)("h3",{className:"font-semibold",children:"By repository URL"}),(0,o.jsx)("p",{children:"Add a Composer package from a Git repository."}),r?(0,o.jsx)("a",{className:"inline-flex min-h-11 items-center underline",href:b,children:"By repository URL"}):(0,o.jsx)("p",{children:"A source manager can add a Git repository."})]})]}):null,(0,o.jsxs)("div",{className:"rounded border p-4",children:[(0,o.jsx)("h3",{className:"font-semibold",children:"Import configuration"}),(0,o.jsx)("p",{children:"Bring source and package selections from a Satis configuration using the CLI."}),(0,o.jsx)("code",{className:"break-all",children:"pb import satis plan"}),i?(0,o.jsx)("a",{href:"#/import",className:"flex min-h-11 items-center underline",children:"Import review"}):(0,o.jsx)("p",{children:"An organization import manager can review imports."})]}),(0,o.jsxs)("div",{className:"lg:col-span-2",children:[(0,o.jsx)("h3",{className:"font-semibold",children:"Upload a private package"}),(0,o.jsx)("p",{children:"Publish a package archive for this project."}),(0,o.jsx)("p",{children:"Coming soon \xB7 Upload and publishing belong to #947."})]})]})}function gt({services:t,project:e,onSourcesChanged:r}){let i=(0,V.useMemo)(()=>wt(t,e),[t,e]),a=(0,V.useSyncExternalStore)(i.subscribe,i.snapshot,i.snapshot),b=a.loading?null:JSON.stringify(a.sources.map(y=>[y.id,y.name]));(0,V.useEffect)(()=>{b!==null&&r?.(a.project?.slug??e,b)},[b,r,a.project?.slug,e]);let[m,k]=(0,V.useState)(null),[s,N]=(0,V.useState)("composer"),[h,S]=(0,V.useState)(""),[v,w]=(0,V.useState)(!1),[l,q]=(0,V.useState)(""),f=(0,V.useRef)(null);(0,V.useEffect)(()=>{i.load()},[i]),(0,V.useEffect)(()=>{(a.notice||a.error)&&f.current?.focus()},[a.notice,a.error]);let g=a.sources.find(y=>y.id===h),A=a.permissions.includes("project:sources:write"),D=a.organization.includes("org:sources:write"),u=e===null?D:A,_=a.sources.filter(y=>m!=="mirror"||y.ecosystem===s&&Me(y)),R=g&&(m==="mirror"?A&&!!a.project:mt(g,a.organization,a.permissions,a.project?.id??null)),B=`#/sources?create=vcs${e?`&project=${encodeURIComponent(e)}`:""}`;function G(y){S(""),w(!1),q(""),i.clearFeedback(),k(y)}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{className:"my-3 text-neutral-600",children:e?`Packages available to ${a.project?.name??e}.`:"Packages available across your organization."}),(0,o.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,o.jsx)(x,{className:"min-h-11",onClick:()=>G("choices"),children:"Add package"}),(0,o.jsx)(x,{className:"min-h-11",variant:"outline",onClick:()=>G("sync"),children:"Sync from source"})]}),m?(0,o.jsx)(ce,{open:!0,onOpenChange:y=>{y||k(null)},children:(0,o.jsxs)(le,{variant:"source",className:"lg:max-w-5xl",children:[(0,o.jsxs)(ue,{className:"shrink-0 p-6 pr-16",children:[(0,o.jsx)(de,{children:m==="sync"?"Sync from source":"Add package"}),(0,o.jsx)(me,{children:m==="sync"?"Check a source for package updates.":a.project?`Add packages to ${a.project.name}.`:"Choose how to add packages to a project."})]}),(0,o.jsxs)("div",{className:"min-h-0 overflow-y-auto px-6 pb-6",children:[a.loading?(0,o.jsx)("p",{role:"status",children:"Loading sources\u2026"}):null,m==="choices"?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)($,{htmlFor:"choice-ecosystem",children:"Ecosystem"}),(0,o.jsxs)(H,{className:"mb-4 min-h-11",id:"choice-ecosystem",value:s,onChange:y=>N(y.target.value),children:[(0,o.jsx)("option",{value:"composer",children:"Composer"}),(0,o.jsx)("option",{value:"npm",children:"npm"})]}),(0,o.jsx)(xt,{ecosystem:s,mirror:e===null?a.projects.length>0:A,setup:u,imported:a.organization.includes("org:import:write"),sourceLink:B,onMirror:()=>k("mirror")})]}):(0,o.jsxs)("form",{id:"source-action-form",className:"grid gap-4 lg:grid-cols-2",onSubmit:y=>{y.preventDefault(),g&&i.submit(m,g.id,l)},children:[e===null?(0,o.jsxs)("div",{children:[(0,o.jsx)($,{htmlFor:"destination-project",children:"Project"}),(0,o.jsxs)(H,{id:"destination-project",className:"min-h-11",disabled:a.busy,value:a.project?.slug??"",onChange:y=>{S(""),w(!1),i.selectProject(y.target.value||null)},children:[(0,o.jsx)("option",{value:"",children:m==="sync"?"Organization sources":"Choose a project"}),a.projects.map(y=>(0,o.jsx)("option",{value:y.slug,children:y.name},y.id))]})]}):null,m==="mirror"?(0,o.jsxs)("div",{children:[(0,o.jsx)($,{htmlFor:"mirror-ecosystem",children:"Ecosystem"}),(0,o.jsxs)(H,{id:"mirror-ecosystem",className:"min-h-11",value:s,disabled:a.busy,onChange:y=>{N(y.target.value),S(""),w(!1)},children:[(0,o.jsx)("option",{value:"composer",children:"Composer"}),(0,o.jsx)("option",{value:"npm",children:"npm"})]})]}):null,(0,o.jsxs)("div",{children:[(0,o.jsx)($,{htmlFor:"package-source",children:"Source"}),(0,o.jsxs)(H,{id:"package-source",className:"min-h-11",required:!0,"aria-invalid":v||void 0,"aria-describedby":v?"package-source-error":void 0,onInvalid:()=>w(!0),disabled:a.loading||a.busy,value:h,onChange:y=>{S(y.target.value),w(!1),i.clearFeedback()},children:[(0,o.jsx)("option",{value:"",children:"Choose a source"}),_.map(y=>(0,o.jsxs)("option",{value:y.id,children:[y.name," \xB7 ",ge[y.type]," \xB7 ",dt(y)]},y.id))]}),v?(0,o.jsx)("p",{id:"package-source-error",role:"alert",children:"Choose a source."}):null]}),m==="mirror"?(0,o.jsxs)("div",{children:[(0,o.jsx)($,{htmlFor:"mirror-package",children:"Find a package"}),(0,o.jsx)(ke,{id:"mirror-package",className:"min-h-11",required:!0,maxLength:428,disabled:a.busy,value:l,onChange:y=>{q(y.target.value),i.clearFeedback()},"aria-describedby":"mirror-help"}),(0,o.jsx)("p",{id:"mirror-help",children:"This source does not support search. Enter the full package name."})]}):null,(0,o.jsxs)("div",{className:"space-y-3 lg:col-span-2",children:[!_.length&&!a.loading?(0,o.jsx)("p",{children:a.project?`No sources available for ${a.project.name}. Attach a source before adding packages.`:m==="mirror"?"Choose a destination project before adding packages.":"No sources available."}):null,!_.length&&u&&!a.loading?(0,o.jsx)("a",{className:"inline-flex min-h-11 items-center underline",href:`#/sources${a.project?`?project=${encodeURIComponent(a.project.slug)}`:""}`,children:"Manage sources"}):null,g?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{children:g.projectId===null?"Shared organization source":`Only ${a.project?.name??e}`}),(0,o.jsx)("p",{children:dt(g)}),g.status==="paused"?(0,o.jsx)("p",{children:"This source is paused. Enable it before syncing."}):null,m==="sync"&&a.requested.includes(g.id)&&!a.notice?(0,o.jsx)("p",{role:"status",children:$e}):null,m==="sync"?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("h3",{className:"font-semibold",children:Me(g)||["packagist_proxy","npmjs_proxy"].includes(g.type)?"Check cached packages for updates":"All configured packages"}),(0,o.jsx)("p",{children:Nt(g)}),g.type==="composer_repository"&&g.config&&"selection"in g.config?(0,o.jsxs)("p",{className:"break-words",children:["Configured selection:"," ",[...g.config.selection?.packages??[],...g.config.selection?.patterns??[]].join(", ")||"No packages selected."]}):null,g.projectId===null?(0,o.jsx)("p",{children:"This source is shared. Updated metadata can be used by other attached projects."}):null,R?null:(0,o.jsx)("p",{children:g.projectId===null?"An organization source manager can sync this source.":"A project source manager can sync this source."})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{children:"Checks this source and queues the package if it is not already available."}),(0,o.jsx)("p",{children:"This syncs the selected packages. Dependencies are fetched through your project's sources when requested."})]})]}):null]})]}),a.notice||a.error?(0,o.jsxs)("div",{ref:f,tabIndex:-1,className:"mt-4 break-words",role:a.error?"alert":"status","aria-live":"polite",children:[(0,o.jsx)("h3",{className:"font-semibold",children:a.error?"Request could not be completed":"Request outcome"}),(0,o.jsx)("p",{children:a.error??a.notice}),a.available?(0,o.jsx)("a",{className:"inline-flex min-h-11 items-center underline",href:Re("packages",{project:a.project?.slug??null,q:a.available.name,source:a.available.source}),children:"View"}):null,a.notice?(0,o.jsx)("a",{className:"inline-flex min-h-11 items-center underline",href:`#/sources${a.project?`?project=${encodeURIComponent(a.project.slug)}`:""}`,children:"View sources"}):null]}):null]}),(0,o.jsx)(pe,{className:"shrink-0 border-t bg-white p-4 pb-[max(1rem,env(safe-area-inset-bottom))]",children:m!=="choices"&&R&&g?.status!=="paused"?(0,o.jsx)(x,{className:"min-h-11",form:"source-action-form",type:"submit",disabled:a.busy||a.loading||!!a.notice||m==="sync"&&a.requested.includes(g.id),children:a.busy?"Requesting\u2026":m==="mirror"?"Add package":"Request source sync"}):null})]})}):null]})}var I=U(Ce(),1);var L=U(J(),1),Pt={not_checked:"Not checked",disabled:"Vulnerability checks disabled",unsupported_version:"Not checked: unsupported version",pending:"Not checked yet",upstream_unavailable:"Check unavailable; no result yet",incomplete:"Check incomplete; no complete result yet",expired:"Outdated result"},At={affected:{icon:"!",color:"border-red-200 bg-red-50 text-red-800"},not_affected:{icon:"i",color:"border-blue-200 bg-blue-50 text-blue-800"},unknown:{icon:"?",color:"border-neutral-200 bg-neutral-100 text-neutral-700"},stale:{icon:"\u25F7",color:"border-amber-300 bg-amber-50 text-amber-900"}};function Ct(t){return t.length<=200&&/^[A-Za-z0-9]/.test(t)&&!/[^A-Za-z0-9._-]/.test(t)?`https://osv.dev/vulnerability/${encodeURIComponent(t)}`:void 0}function ft({assessment:t,sourceType:e}){let{status:r,reason:i}=t,a=r==="unknown"&&i==="not_checked",b=["vcs","composer_repository","npm_registry","hosted"].includes(e),m=r==="affected"?`Known advisories: ${t.advisoryCount}`:r==="not_affected"?"No known advisories":r==="stale"?"Outdated result":a&&b?"Not checked: private package":i===null?"Not checked":Pt[i],k=At[r];return(0,L.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,L.jsxs)(Je,{variant:"outline",className:k.color,children:[(0,L.jsx)("span",{"aria-hidden":"true",children:k.icon})," ",m]}),a?(0,L.jsx)("p",{children:"Only verified public proxy packages are checked."}):(0,L.jsxs)(L.Fragment,{children:[t.source==="osv"?(0,L.jsxs)("p",{children:["OSV \xB7 ",r==="stale"?"Last checked":"checked"," ",(0,L.jsx)(K,{value:t.fetchedAt,fallback:"No successful check yet"})]}):null,r==="stale"&&t.lastKnownStatus!==null?(0,L.jsx)("p",{children:t.lastKnownStatus==="affected"?`Last result: known advisories: ${t.advisoryCount}`:"Last result: no known advisories"}):null,(0,L.jsxs)("details",{children:[(0,L.jsx)("summary",{className:"cursor-pointer",children:"Advisory check details"}),r==="stale"&&i==="incomplete"?(0,L.jsx)("p",{children:"Check incomplete; last complete result shown."}):null,t.advisoryCount>0&&!t.detailsComplete?(0,L.jsx)("p",{children:"Advisory details pending"}):null,t.advisoriesTruncated?(0,L.jsxs)("p",{children:["Showing ",t.advisories.length," of ",t.advisoryCount," advisories"]}):null,t.advisories.length>0?(0,L.jsx)("ul",{className:"list-disc pl-5",children:t.advisories.map(s=>{let N=Ct(s.id);return(0,L.jsxs)("li",{children:[N?(0,L.jsx)("a",{href:N,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",className:"underline",children:s.id}):s.id," \xB7 ",s.severity.level==="unknown"?"Severity unavailable":`Severity: ${s.severity.level}`,s.detailsFetchedAt===null?(0,L.jsx)("span",{children:" \xB7 Advisory details pending"}):(0,L.jsxs)("span",{children:[" ","\xB7 Details fetched ",(0,L.jsx)(K,{value:s.detailsFetchedAt})]})]},s.id)})}):null]})]})]})}var n=U(J(),1),bt=["active","quarantined","tombstoned","removed_upstream"],Rt={quarantine:"Quarantine",tombstone:"Tombstone",release:"Release"},ht=t=>Xe[t];function kt(t){return t.organization.includes("org:packages:manage")?"Organization":`Project ${t.projectSlug}`}function fe(t){let e=new URLSearchParams(Ke(t).split("?")[1]),r={project:e.get("project")},i=e.get("status");bt.includes(i)&&(r.status=i);let a=e.get("source");a!==null&&(r.source=a);let b=e.get("projectId");r.project===null&&b!==null&&(r.projectId=b);let m=e.get("q")?.trim().toLowerCase();m&&m.length<=100&&!m.includes("\0")&&(r.q=m);let k=e.get("after");return k!==null&&(r.after=k),r}function ve(t){return Re("packages",t)}function vt(t,e,r){let i=r.organization.includes("org:packages:manage"),a=r.projectSlug!==null&&r.projectId!==null&&r.project.includes("project:packages:manage")&&t.source.projectId===r.projectId;if(!i&&!a)return[];let b=[];return(e==="active"||e==="removed_upstream")&&b.push("quarantine"),(e==="active"||e==="removed_upstream"||e==="quarantined")&&b.push("tombstone"),e==="quarantined"&&b.push("release"),b}function _t(t){let e={query:{project:null},items:[],next:null,access:{organization:[],project:[],projectId:null,projectSlug:null},selected:null,versions:[],versionsNext:null,loading:!1,versionsLoading:!1,busy:!1,notice:null,confirmVersion:null},r=new Set,i=f=>{e={...e,...f};for(let g of r)g()},a=0,b=0,m=0,k=null,s,N=t.client;async function h(f,g=null){let A=++a;++b,k=null,i({query:f,items:[],next:null,selected:null,versions:[],versionsNext:null,confirmVersion:null,loading:!0,listError:!1,versionsError:!1,versionsLoading:!1,busy:!1,notice:g,access:{organization:[],project:[],projectId:null,projectSlug:f.project}});let D={status:f.status,source:f.source,q:f.q,after:f.after},[u,_,R,B]=await Promise.all([N.request("get","/_pb/me/permissions"),f.project===null?null:N.request("get","/_pb/projects/{project}/permissions",{params:{project:f.project}}),f.project===null?null:N.request("get","/_pb/projects/{project}",{params:{project:f.project}}),f.project===null?N.request("get","/_pb/packages",{query:{...D,project:f.projectId}}):N.request("get","/_pb/projects/{project}/packages",{params:{project:f.project},query:D})]);A===a&&(k=B.ok?ve(f):null,i({loading:!1,listError:!B.ok,access:{organization:u.ok?u.data.organization:[],project:_?.ok?_.data.project:[],projectId:R?.ok?R.data.id:null,projectSlug:f.project},items:B.ok?B.data.items:[],next:B.ok?B.data.next:null,notice:[g,B.ok?null:B.status===404?"Not found.":"Packages could not be loaded. Try again."].filter(Boolean).join(" ")||null}))}async function S(f,g){if(e.busy||e.loading)return;let A=e.items.find(B=>B.id===f);if(!A)return;let D=++b,u=a,_=e.query.project;s=g,i({selected:A,versions:[],versionsNext:null,versionsLoading:!0,versionsError:!1,confirmVersion:null});let R=_===null?await N.request("get","/_pb/packages/{package}/versions",{params:{package:f},query:{after:g}}):await N.request("get","/_pb/projects/{project}/packages/{package}/versions",{params:{project:_,package:f},query:{after:g}});D!==b||u!==a||i({versionsLoading:!1,versionsError:!R.ok,versions:R.ok?R.data.items:[],versionsNext:R.ok?R.data.next:null,notice:R.ok?e.notice:R.status===404?"Not found.":"Versions could not be loaded. Try again."})}function v(){++b,s=void 0,i({selected:null,versions:[],versionsNext:null,versionsLoading:!1,confirmVersion:null})}async function w(f,g,A){let D=++m;k!==ve(f)&&await h(f),D===m&&(g?await S(g,A):v())}async function l(f=null){let g=e.selected?.id,A=s,D=a,u=m;await h(e.query,f),a===D+1&&u===m&&g&&await S(g,A)}async function q(f,g,A=!1,D=""){let u=e.selected,_=e.versions.find(Z=>Z.id===f);if(e.busy||e.loading||e.versionsLoading||!u||!_||!vt(u,_.status,e.access).includes(g))return;if(g==="tombstone"&&!A){i({confirmVersion:f});return}let R=a,B=b,G=e.query,y={package:u.id,version:_.id},W=e.access.projectSlug;i({busy:!0,notice:null});let z=e.access.organization.includes("org:packages:manage")?await N.request("post",`/_pb/packages/{package}/versions/{version}/${g}`,{params:y,body:g==="tombstone"?{reason:D}:{}}):await N.request("post",`/_pb/projects/{project}/packages/{package}/versions/{version}/${g}`,{params:{...y,project:W},body:g==="tombstone"?{reason:D}:{}});if(!(R!==a||B!==b)){if(i({busy:!1}),!z.ok&&z.code==="reauth_required"){i({confirmVersion:null}),t.requireReauth(z.request,{credential:!1,secretFields:[],display:{packageName:u.name,version:_.version,scope:kt(e.access)}});return}if(!z.ok&&z.status===404){await h(G,"Not found.");return}if(!z.ok){i({notice:z.status===409?"The version changed, refresh.":"The action could not be completed. Try again."});return}await h(G,"Version updated."),a===R+1&&await S(u.id)}}return{snapshot:()=>e,subscribe(f){return r.add(f),()=>{r.delete(f)}},async replayed(f){let g=e.query.project===null?null:`/_pb/projects/${encodeURIComponent(e.query.project)}/packages/`,A=f.path.startsWith("/_pb/packages/")?f.path.slice(14):g!==null&&f.path.startsWith(g)?f.path.slice(g.length):null;A===null||!/^[^/]+\/versions\/[^/]+\/(quarantine|tombstone|release)$/.test(A)||await l(f.ok?"Version updated.":f.status===404?"Not found.":f.status===409?"The version changed, refresh.":"The action could not be completed. Try again.")},load:h,open:S,navigate:w,refresh:l,act:q,close:v,cancelTombstone:()=>i({confirmVersion:null}),async confirmTombstone(f){if(!f.trim()||new TextEncoder().encode(f).byteLength>1e3)return;let g=e.confirmVersion;g!==null&&await q(g,"tombstone",!0,f)},dispose(){++m,++a,++b}}}function Oe(t){return(0,n.jsx)(oe,{label:`Versions of ${t.item.name}`,items:t.versions,columns:[{key:"version",label:"Version",value:e=>e.version,render:e=>(0,n.jsx)("span",{className:"font-mono",children:e.version})},{key:"status",label:"Status",value:e=>e.status,render:e=>(0,n.jsx)(_e,{status:e.status})},{key:"vulnerability",label:"Known vulnerabilities",value:e=>e.vulnerability.status,render:e=>(0,n.jsx)(ft,{assessment:e.vulnerability,sourceType:t.item.source.type})},{key:"published",label:"Published",priority:2,value:e=>e.publishedAt??"",render:e=>(0,n.jsx)(K,{value:e.publishedAt})},{key:"actions",label:"Actions",value:()=>"",render:e=>(0,n.jsx)("div",{className:"flex flex-wrap gap-2",children:vt(t.item,e.status,t.access).map(r=>(0,n.jsx)(x,{type:"button",size:"sm",variant:r==="tombstone"?"ghost":"outline",className:r==="tombstone"?"text-red-700":void 0,disabled:t.busy,"data-package-action":r,onClick:()=>t.onAction(e.id,r),children:Rt[r]},r))})}]})}function Et(t){let{state:e}=t,[r,i]=(0,I.useState)("");(0,I.useEffect)(()=>{e.confirmVersion!==null&&i("")},[e.confirmVersion]);let a=new TextEncoder().encode(r).byteLength,b=r.trim().length>0&&a<=1e3,m=e.versions.find(s=>s.id===e.confirmVersion),k=!!(e.query.q||e.query.status||e.query.source||e.query.projectId||e.query.after);return(0,n.jsxs)(n.Fragment,{children:[e.notice?(0,n.jsx)(Qe,{className:"my-4",children:(0,n.jsx)(Ge,{children:e.notice})}):null,(0,n.jsxs)("div",{className:"my-4 flex flex-wrap items-center gap-3",children:[(0,n.jsx)("span",{className:"mr-auto text-neutral-600",children:e.selected?e.selected.name:`${e.items.length} packages on this page`}),(0,n.jsx)(x,{type:"button",variant:"outline",onClick:t.onRefresh,disabled:e.loading||e.busy,children:"Refresh"})]}),e.selected===null?e.loading?(0,n.jsx)(Q,{kind:"loading",title:"Loading packages\u2026"}):e.items.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(oe,{label:"Packages",items:e.items,columns:[{key:"name",label:"Name",value:s=>s.name,render:s=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x,{type:"button",variant:"link",className:"h-auto min-h-11 max-w-full justify-start whitespace-normal break-words p-0 text-left",disabled:e.busy,onClick:()=>t.onOpen(s.id),children:s.name}),(0,n.jsx)("span",{className:"block text-xs text-neutral-600",children:s.ecosystem})]})},{key:"status",label:"Status",value:s=>s.status,render:s=>(0,n.jsx)(_e,{status:s.status})},{key:"latest",label:"Latest version",value:s=>s.latestVersion??"",render:s=>(0,n.jsx)("span",{className:"font-mono",children:s.latestVersion??"\u2014"})},{key:"source",label:"Winning source",priority:2,value:s=>s.source.name,render:s=>(0,n.jsxs)(n.Fragment,{children:[s.source.name,(0,n.jsx)("span",{className:"block text-xs text-neutral-600",children:ge[s.source.type]})]})},{key:"count",label:"Version count",priority:2,value:s=>s.versionCount},{key:"synced",label:"Last synced",priority:3,value:s=>s.lastSyncedAt??"",render:s=>(0,n.jsx)(K,{value:s.lastSyncedAt,fallback:"Never"})}]}),e.next?(0,n.jsx)(x,{type:"button",className:"my-4",variant:"outline",disabled:e.busy,onClick:t.onNext,children:"Next packages"}):null]}):e.listError?(0,n.jsx)(Q,{kind:"error",title:"Packages could not be loaded",children:(0,n.jsx)(x,{type:"button",variant:"outline",onClick:t.onRefresh,children:"Retry"})}):(0,n.jsx)(Q,{kind:k?"filtered-empty":"empty",title:k?"No packages match these filters":"No packages yet",children:k?"Change or clear the filters to see more packages.":`No packages yet. Add a package from a connected source, or attach a source to get started. ${st}`}):(0,n.jsxs)("section",{"aria-labelledby":"versions-heading",className:"space-y-4",children:[(0,n.jsx)(x,{type:"button",variant:"link",className:"px-0",onClick:t.onBack,disabled:e.busy,children:"\u2190 Back to packages"}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsxs)("h2",{id:"versions-heading",className:"text-lg font-semibold break-all",children:["Versions of ",e.selected.name]}),(0,n.jsx)(_e,{status:e.selected.status})]}),(0,n.jsx)(Ye,{value:e.selected.id,label:"package ID"}),e.versionsLoading?(0,n.jsx)(Q,{kind:"loading",title:"Loading versions\u2026"}):e.versions.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Oe,{item:e.selected,versions:e.versions,access:e.access,busy:e.busy,onAction:t.onAction}),e.versionsNext?(0,n.jsx)(x,{type:"button",variant:"outline",disabled:e.busy,onClick:t.onVersionNext,children:"Next versions"}):null]}):(0,n.jsx)(Q,{kind:e.versionsError?"error":"empty",title:e.versionsError?"Versions could not be loaded":"No versions found."})]}),e.confirmVersion!==null?(0,n.jsx)(ce,{open:!0,onOpenChange:s=>{s||t.onCancel()},children:(0,n.jsxs)(le,{children:[(0,n.jsxs)(ue,{children:[(0,n.jsxs)(de,{children:["Tombstone ",m?.version??"version","?"]}),(0,n.jsx)(me,{children:"This removes the version from package resolution. Clients can no longer install it. Only this version is affected. This cannot be undone."})]}),(0,n.jsxs)("dl",{className:"detail-list",children:[(0,n.jsx)("dt",{children:"Package"}),(0,n.jsx)("dd",{children:e.selected?.name}),(0,n.jsx)("dt",{children:"Version"}),(0,n.jsx)("dd",{className:"font-mono",children:m?.version}),(0,n.jsx)("dt",{children:"Scope"}),(0,n.jsx)("dd",{children:kt(e.access)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)($,{htmlFor:"tombstone-reason",children:"Reason (required)"}),(0,n.jsx)(ke,{id:"tombstone-reason",disabled:e.busy,required:!0,value:r,"aria-describedby":"tombstone-reason-help","aria-invalid":a>1e3,onChange:s=>i(s.target.value)}),(0,n.jsxs)("p",{id:"tombstone-reason-help",children:["Enter a reason of 1\u20131000 UTF-8 bytes. ",a," bytes used."]})]}),(0,n.jsxs)(pe,{children:[(0,n.jsx)(x,{type:"button",variant:"outline",onClick:t.onCancel,children:"Cancel"}),(0,n.jsx)(x,{type:"button",variant:"destructive",disabled:!b||e.busy,onClick:()=>t.onConfirm(r),children:"Confirm tombstone"})]})]})}):null]})}function Tt(t){let e=new Map;return Object.assign(i=>{let a=e.get(i);if(a)return a;let b=(async()=>{let m=[],k,s=!0;do{let h=i===null?await t.client.request("get","/_pb/sources",{query:{after:k}}):await t.client.request("get","/_pb/projects/{project}/sources",{params:{project:i},query:{after:k}});if(!h.ok){s=!1;break}m.push(...h.data.items),k=h.data.next??void 0}while(k);let N=[];if(i===null){k=void 0;do{let h=await t.client.request("get","/_pb/projects",{query:{after:k}});if(!h.ok){s=!1;break}N.push(...h.data.items),k=h.data.next??void 0}while(k)}return s||e.delete(i),{sources:m,projects:N}})();return e.set(i,b),b},{invalidate:()=>e.clear()})}function Lt(t){let[e,r]=(0,I.useState)(t.query),{q:i,status:a,source:b,projectId:m,project:k}=t.query;(0,I.useEffect)(()=>{r({project:k,...i?{q:i}:{},...a?{status:a}:{},...b?{source:b}:{},...m?{projectId:m}:{}})},[i,a,b,m,k]);let[s,N]=(0,I.useState)(null);(0,I.useEffect)(()=>{let l=!0;return N(null),t.loadChoices(t.query.project).then(q=>{l&&N(q)}),()=>{l=!1}},[t.loadChoices,t.query.project,t.choicesRevision]);let h=s?.sources??[],S=s?.projects??[],v=s!==null;function w(l){l.preventDefault();let q=new FormData(l.currentTarget),f=new URLSearchParams;t.query.project!==null&&f.set("project",t.query.project);for(let g of["status","source","projectId","q"]){let A=q.get(g);typeof A=="string"&&A.trim()!==""&&f.set(g,A.trim())}t.onChange(fe(`#/packages?${f}`))}return(0,n.jsx)(et,{chips:["q","status","source","projectId"].flatMap(l=>t.query[l]&&(v||l!=="source"&&l!=="projectId")?[{label:{q:"Name prefix",status:"Status",source:"Source",projectId:"Project"}[l],value:l==="source"?h.find(q=>q.id===t.query.source)?.name??"Name unavailable":l==="projectId"?S.find(q=>q.id===t.query.projectId)?.name??"Name unavailable":l==="status"?ht(t.query.status):t.query[l],onRemove:()=>{let q={...t.query};delete q[l],delete q.after,t.onChange(q)}}]:[]),children:(0,n.jsxs)("form",{onSubmit:w,className:"my-4 flex flex-wrap items-end gap-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)($,{htmlFor:"package-q",children:"Name prefix"}),(0,n.jsx)(ke,{id:"package-q",name:"q",maxLength:100,value:e.q??"",onChange:l=>r(q=>({...q,q:l.target.value}))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)($,{htmlFor:"package-status",children:"Status"}),(0,n.jsxs)(H,{id:"package-status",name:"status",value:e.status??"",onChange:l=>r(q=>({...q,status:l.target.value})),children:[(0,n.jsx)("option",{value:"",children:"All statuses"}),bt.map(l=>(0,n.jsx)("option",{value:l,children:ht(l)},l))]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)($,{htmlFor:"package-source",children:"Source"}),(0,n.jsxs)(H,{className:"min-h-11",id:"package-source",name:"source",value:e.source??"",onChange:l=>r(q=>({...q,source:l.target.value})),disabled:!v,children:[(0,n.jsx)("option",{value:"",children:"All sources"}),t.query.source&&!h.some(l=>l.id===t.query.source)&&(0,n.jsx)("option",{value:t.query.source,children:"Name unavailable"}),h.map(l=>(0,n.jsx)("option",{value:l.id,children:l.name},l.id))]})]}),t.query.project===null?(0,n.jsxs)("div",{children:[(0,n.jsx)($,{htmlFor:"package-project",children:"Project"}),(0,n.jsxs)(H,{className:"min-h-11",id:"package-project",name:"projectId",value:e.projectId??"",onChange:l=>r(q=>({...q,projectId:l.target.value})),disabled:!v,children:[(0,n.jsx)("option",{value:"",children:"All projects"}),t.query.projectId&&!S.some(l=>l.id===t.query.projectId)&&(0,n.jsx)("option",{value:t.query.projectId,children:"Name unavailable"}),S.map(l=>(0,n.jsx)("option",{value:l.id,children:l.name},l.id))]})]}):null,(0,n.jsx)(x,{type:"submit",children:"Apply filters"}),(0,n.jsx)(x,{type:"reset",variant:"outline",onClick:()=>t.onChange({project:t.query.project}),children:"Clear filters"})]})})}function Ea(){let t=Ze(),e=(0,I.useMemo)(()=>_t(t),[t]),[r,i]=(0,I.useState)(0),a=(0,I.useMemo)(()=>Tt(t),[t]),b=(0,I.useRef)(new Map),m=(0,I.useCallback)((v,w)=>{if(v!==void 0&&w!==void 0){let l=b.current.get(v);if(b.current.set(v,w),l===void 0||l===w)return}a.invalidate(),i(l=>l+1)},[a]),k=(0,I.useSyncExternalStore)(e.subscribe,e.snapshot,e.snapshot),[s,N]=(0,I.useState)(()=>typeof window>"u"?"#/packages":window.location.hash);(0,I.useEffect)(()=>{let v=()=>N(window.location.hash);return window.addEventListener("hashchange",v),()=>window.removeEventListener("hashchange",v)},[]),(0,I.useEffect)(()=>{if(/^#\/packages\//.test(s))return;let v=new URLSearchParams(s.split("?")[1]);return e.navigate(fe(s),v.get("package")??void 0,v.get("versionAfter")??void 0),()=>e.dispose()},[e,s]),(0,I.useEffect)(()=>t.subscribeReplay?.(v=>{v.ok&&/\/sources(?:\/|$)/.test(v.path)&&m(),e.replayed(v)}),[t,e,m]);let h=v=>{window.location.hash=ve(v)},S=/^#\/packages\/([^?]+)(?:\?|$)/.exec(s);return S?(0,n.jsx)(pt,{services:t,id:S[1],project:fe(s).project,back:ve(fe(s))},s):(0,n.jsxs)("section",{"aria-labelledby":"page-heading",children:[(0,n.jsx)("h1",{tabIndex:-1,id:"page-heading",className:"text-2xl font-semibold",children:"Packages"}),k.selected===null?(0,n.jsx)(ut,{services:t,project:fe(s).project},k.query.project):null,k.selected===null?(0,n.jsx)(gt,{services:t,project:k.query.project,onSourcesChanged:m},k.query.project):null,k.selected===null?(0,n.jsx)(Lt,{loadChoices:a,choicesRevision:r,query:fe(s),onChange:h}):null,(0,n.jsx)(Et,{state:k,onOpen:v=>{let w=new URLSearchParams(ve(k.query).split("?")[1]);window.location.hash=`#/packages/${v}${w.size?`?${w}`:""}`},onBack:()=>h(k.query),onAction:(v,w)=>{e.act(v,w)},onNext:()=>{k.next!==null&&h({...k.query,after:k.next})},onVersionNext:()=>{if(k.selected&&k.versionsNext){let v=new URLSearchParams(s.split("?")[1]);v.set("versionAfter",k.versionsNext),window.location.hash=`#/packages?${v}`}},onRefresh:()=>{e.refresh()},onConfirm:v=>{e.confirmTombstone(v)},onCancel:e.cancelTombstone})]})}export{Oe as PackageVersions,Ea as PackagesPage,Et as PackagesView,ve as buildPackagesHash,Tt as createPackageFilterChoicesLoader,_t as createPackagesController,vt as packageActions,fe as parsePackagesHash};
@@ -0,0 +1 @@
1
+ import{a as K,b as Z,c as P,d as X,h as ee,i as te,j as se}from"./chunk.6ea6bdcaa465.js";import"./chunk.28a4d8aab337.js";import{b as J}from"./chunk.8442124f6802.js";import{a as D}from"./chunk.a6d755a9789f.js";import{a as Y,c as V}from"./chunk.965b76812604.js";import"./chunk.3fcd6998795a.js";import"./chunk.741aec8d1ff9.js";import{D as G,E as L,F as T,K as W,c as N,d as Q,g as M,j as q,p as $}from"./chunk.fd375c54b526.js";var E=N(Q(),1);var j=N(Q(),1);var U=/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/,A="1\u201364 lowercase letters, numbers or hyphens. Start and end with a letter or number.";function z(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64).replace(/-+$/g,"")}function ae(e,t){return{...e,name:t,slug:e.manualSlug?e.slug:z(t)}}function oe(e,t){return{...e,slug:t,manualSlug:!0}}function ne(e){return{...e,slug:z(e.name),manualSlug:!1}}function re(e,t=!1){let n={};return e.name.trim()?[...e.name].length>100?n.name="Use 100 characters or fewer.":/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Cs}]/u.test(e.name)&&(n.name="Use a name without control or formatting characters."):n.name="Enter a project name.",!t&&!U.test(e.slug)&&(n.slug=!e.slug&&e.name&&!z(e.name)?"Enter a project slug using lowercase letters, numbers or hyphens.":A),n}function ie(e,t){return{name:e.name,tokenMaxScope:e.tokenMaxScope,...t?{}:{slug:e.slug}}}function le(e,t){if(e.ok)return{};if(!t&&e.code==="duplicate")return{slug:"This project slug is already in use. Choose another."};let n={};for(let a of e.details)a.location&&a.location!=="body"||(a.path==="/body/name"&&(n.name="Check the entered values and try again."),!t&&a.path==="/body/slug"&&(n.slug=A),a.path==="/body/tokenMaxScope"&&(n.tokenMaxScope="Check the entered values and try again."));return n}var pe="This change limits existing personal and service tokens on their next request. Downloads can continue, but access above this limit will stop. Check any CI jobs that use these tokens.";function ce(e,t){let n=["read","write","full"];return e===t?null:n.indexOf(t)<n.indexOf(e)?pe:"Existing tokens may regain access if their scope and permissions allow it."}var o=N(M(),1),ue=[{value:"read",label:"Install and download",summary:"Install and download only",description:"Read project details and download packages."},{value:"write",label:"Include publish permission",summary:"Publish permission included",description:"Also allow the package publishing permission. Publish npm packages to an enabled hosted source that claims the package name."},{value:"full",label:"Include grants, sources and audit access",summary:"Grants, sources and audit access included",description:"Also allow reading project grants, sources and audit records, plus the publish permission."}];function F(e){let t=(0,j.useId)(),n=(0,j.useRef)(null),a=(0,j.useRef)(null),h=(0,j.useRef)(null),u=!!e.project,[s,l]=(0,j.useState)({name:e.project?.name??"",slug:e.project?.slug??"",tokenMaxScope:e.project?.tokenMaxScope??"read",manualSlug:!1}),[r,f]=(0,j.useState)({}),[p,x]=(0,j.useState)(!1),[b,I]=(0,j.useState)(""),m=c=>{f(c);let v=["name","slug","tokenMaxScope"].find(g=>c[g]);v==="tokenMaxScope"&&a.current&&(a.current.open=!0),v&&n.current?.querySelector(`[name="${v}"]`)?.focus()},d=U.test(s.slug)?s.slug:"{project-slug}",k=typeof window>"u"?"":window.location.origin,y=e.project?ce(e.project.tokenMaxScope,s.tokenMaxScope):null;return(0,o.jsxs)("form",{ref:n,noValidate:!0,"aria-label":u?"Project settings":"New project",className:"my-6 grid min-w-0 max-w-5xl items-start gap-x-6 gap-y-4 lg:grid-cols-2",onSubmit:async c=>{if(c.preventDefault(),e.disabled||p)return;I("");let v=re(s,u);if(m(v),!Object.keys(v).length){x(!0);try{let g=await e.submit(ie(s,u));if(g&&!g.ok){let w=le(g,u);m(w),Object.keys(w).length||h.current?.focus(),I(g.status===412?"This project changed while you were editing. Reload the latest settings before saving.":P(g))}else g?.ok&&I(u?"Access policy saved. Existing tokens now use this limit.":"Project created.")}finally{x(!1)}}},children:[(0,o.jsxs)("div",{className:"grid min-w-0 gap-1",children:[(0,o.jsx)(T,{htmlFor:`${t}-name`,children:"Project name"}),(0,o.jsx)(L,{id:`${t}-name`,name:"name",required:!0,className:"h-11",placeholder:"e.g. Acme Company",value:s.name,onChange:c=>l(ae(s,c.target.value)),"aria-describedby":`${t}-name-help ${t}-name-error`,"aria-invalid":!!r.name}),(0,o.jsx)("p",{id:`${t}-name-help`,className:"text-sm text-neutral-600",children:"A name your team will recognize. You can change it later."}),(0,o.jsx)("p",{id:`${t}-name-error`,className:"text-sm text-red-700",children:r.name})]}),(0,o.jsxs)("div",{className:"grid min-w-0 gap-1",children:[u?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{className:"text-sm font-medium",children:"Project slug"}),(0,o.jsx)("p",{className:"break-all",children:s.slug})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(T,{htmlFor:`${t}-slug`,children:"Project slug"}),(0,o.jsx)(L,{id:`${t}-slug`,name:"slug",required:!0,className:"h-11",placeholder:"e.g. acme-company",value:s.slug,onChange:c=>l(oe(s,c.target.value)),"aria-describedby":`${t}-slug-help ${t}-slug-rule ${t}-slug-error`,"aria-invalid":!!r.slug}),s.manualSlug?(0,o.jsx)($,{type:"button",variant:"ghost",className:"min-h-11 justify-self-start",onClick:()=>l(ne(s)),children:"Use suggested slug"}):null]}),(0,o.jsx)("p",{id:`${t}-slug-help`,className:"text-sm text-neutral-600",children:"Used in repository URLs and CLI commands. You cannot change it later."}),u?null:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{id:`${t}-slug-rule`,className:"text-sm text-neutral-600",children:A}),(0,o.jsx)("p",{id:`${t}-slug-error`,className:"text-sm text-red-700",children:r.slug})]})]}),(0,o.jsxs)("div",{className:"grid min-w-0 gap-2 rounded-md border border-neutral-300 bg-neutral-50 p-4 lg:col-span-2",children:[(0,o.jsx)("p",{className:"text-sm font-medium",children:"Repository URLs"}),(0,o.jsxs)("dl",{className:"grid min-w-0 gap-2 text-sm",children:[(0,o.jsxs)("div",{className:"min-w-0",children:[(0,o.jsx)("dt",{children:"Composer"}),(0,o.jsx)("dd",{className:"overflow-x-auto whitespace-nowrap",tabIndex:0,children:(0,o.jsx)("code",{children:`${k}/${d}`})})]}),(0,o.jsxs)("div",{className:"min-w-0",children:[(0,o.jsx)("dt",{children:"npm"}),(0,o.jsx)("dd",{className:"overflow-x-auto whitespace-nowrap",tabIndex:0,children:(0,o.jsx)("code",{children:`${k}/${d}/npm/`})})]})]})]}),(0,o.jsxs)("details",{ref:a,className:"min-w-0 rounded-md border border-neutral-300 lg:col-span-2",children:[(0,o.jsxs)("summary",{className:"min-h-11 cursor-pointer p-4 font-medium focus-visible:ring-2 focus-visible:ring-blue-600",children:["Access policy",(0,o.jsx)("span",{className:"block text-sm font-normal text-neutral-600",children:ue.find(c=>c.value===s.tokenMaxScope)?.summary})]}),(0,o.jsxs)("fieldset",{className:"m-4 grid min-w-0 gap-3","aria-describedby":`${t}-policy-help ${t}-policy-note ${t}-policy-error`,children:[(0,o.jsx)("legend",{className:"font-medium",children:"What can tokens do on this project?"}),(0,o.jsx)("p",{id:`${t}-policy-help`,className:"text-sm text-neutral-600",children:"Sets the maximum access for personal and service tokens, including tokens used by CI. Each token still needs its own permissions. Your access in the admin UI is unchanged."}),ue.map(c=>(0,o.jsxs)(T,{htmlFor:`${t}-${c.value}`,className:"flex min-h-11 cursor-pointer items-start gap-3 rounded-md border border-neutral-300 p-3 has-checked:border-blue-700 has-checked:bg-blue-50",children:[(0,o.jsx)("input",{id:`${t}-${c.value}`,type:"radio",name:"tokenMaxScope",value:c.value,checked:s.tokenMaxScope===c.value,onChange:()=>l({...s,tokenMaxScope:c.value}),className:"mt-1 accent-blue-700 focus-visible:ring-2 focus-visible:ring-blue-600","aria-describedby":`${t}-${c.value}-description ${t}-policy-error`,"aria-invalid":!!r.tokenMaxScope}),(0,o.jsxs)("span",{children:[c.label,c.value==="read"?(0,o.jsx)("span",{className:"ml-2 inline-block rounded bg-blue-100 px-1 text-xs text-blue-800",children:"Recommended"}):null,(0,o.jsx)("span",{id:`${t}-${c.value}-description`,className:"mt-1 block text-sm font-normal text-neutral-600",children:c.description})]})]},c.value)),(0,o.jsx)("p",{id:`${t}-policy-note`,className:"text-sm text-neutral-600",children:"Tokens cannot change project settings or delete packages. Publishing is not available in this version."}),(0,o.jsx)("p",{id:`${t}-policy-error`,className:"text-sm text-red-700",children:r.tokenMaxScope})]})]}),e.project?.requirePublishApproval?(0,o.jsx)("p",{className:"text-sm text-neutral-600 lg:col-span-2",children:"Publish approval is saved as required, but approval is not enforced in this version."}):null,y?(0,o.jsx)("p",{className:"text-sm text-neutral-600 lg:col-span-2",children:y}):null,(0,o.jsx)("div",{className:"lg:col-span-2",children:(0,o.jsx)($,{type:"submit",className:"min-h-11 w-full sm:w-auto lg:w-auto",disabled:e.disabled||p,children:p?u?"Saving settings\u2026":"Creating project\u2026":u?"Save settings":(0,o.jsx)(o.Fragment,{children:"Create project"})})}),(0,o.jsx)("p",{ref:h,role:"status",tabIndex:-1,className:"lg:col-span-2",children:p?u?"Saving settings\u2026":"Creating project\u2026":b||(Object.keys(r).length?"Check the entered values and try again.":"")})]})}var i=N(M(),1),S="Project archived.",_=["active","archived"],O=e=>K(e,_),C=e=>q("projects",O(q("projects",e)));async function B(e,t,n=!0){if(t.status)return e.request("get","/_pb/projects",{query:{status:t.status,after:t.after,limit:"50"}});let a=[t.after,void 0];if(t.after?.startsWith("all:"))try{let l=JSON.parse(t.after.slice(4));if(!Array.isArray(l)||l.length!==2||!l.every(r=>r===null||typeof r=="string"))throw new Error("Invalid cursor");a=l}catch{return{ok:!1,status:400,code:"invalid_request",details:[],request:{method:"GET",path:"/_pb/projects"}}}if(!n&&a[0]===null)return{ok:!0,status:200,data:{items:[],next:null}};if(!n)return e.request("get","/_pb/projects",{query:{status:"active",after:a[0]??void 0,limit:"50"}});let h=await Promise.all(_.map((l,r)=>a[r]===null?null:e.request("get","/_pb/projects",{query:{status:l,after:a[r]??void 0,limit:"50"}}))),u=[],s=[];for(let[l,r]of h.entries()){if(r&&!r.ok){if(_[l]==="archived"&&r.status===403){s.push(null);continue}return r}r?.ok&&u.push(...r.data.items),s.push(r?.ok?r.data.next:null)}return{ok:!0,status:200,data:{items:u,next:s.some(l=>l!==null)?`all:${JSON.stringify(s)}`:null}}}function R(e){let t=e.selected,n=!!t&&!!e.etag&&!e.loading&&!e.stale;return{items:e.items.filter(a=>!e.query.q||a.name.toLowerCase().startsWith(e.query.q.toLowerCase())),create:e.organization.includes("org:projects:create")&&!e.stale&&!e.loading,settings:n&&t.status==="active"&&e.permissions.includes("project:settings:write"),transition:n&&e.organization.includes("org:projects:archive"),transitionItems:!e.loading&&!e.stale&&e.organization.includes("org:projects:archive")}}function de(e){let t=Z({query:{project:null},items:[],next:null,selected:null,etag:null,organization:[],permissions:[],loading:!1,listError:!1,busy:!1,stale:!1,notice:null}),n=0,{client:a}=e;async function h(s,l=C(s)===C(t.snapshot().query)&&t.snapshot().notice===S?S:null){let r=++n;t.set({query:s,items:[],next:null,selected:null,etag:null,organization:[],permissions:[],loading:!0,listError:!1,busy:!1,stale:!1,notice:l});let f=a.request("get","/_pb/me/permissions"),[p,x,b,I]=await Promise.all([f.then(y=>B(a,s,y.ok&&y.data.organization.includes("org:projects:archive")&&y.data.organization.includes("project:read"))),f,s.project===null?null:a.request("get","/_pb/projects/{project}",{params:{project:s.project}}),s.project===null?null:a.request("get","/_pb/projects/{project}/permissions",{params:{project:s.project}})]);if(r!==n)return;let m=p,d=b,k=I;if(d&&!d.ok&&d.status===404){let y,c=new Set;for(;;){let v={project:null,status:"archived",after:y},g=await B(a,v);if(r!==n)return;if(!g.ok)break;if(g.data.items.some(H=>H.slug===s.project&&H.status==="archived")){s=v,m=g,d=null,k=null,l=S;break}let w=g.data.next;if(!w||c.has(w))break;c.add(w),y=w}}l===S&&(s={...s,project:null},d=null,k=null,!m.ok&&(s={...s,status:"active",after:void 0},m=await B(a,s),r!==n))||t.set({query:s,loading:!1,listError:!m.ok,items:m.ok?m.data.items:[],next:m.ok?m.data.next:null,organization:x.ok?x.data.organization:[],selected:d?.ok?d.data:null,etag:d?.ok?d.headers?.etag??null:null,permissions:k?.ok?k.data.project:[],notice:m.ok?d&&!d.ok?P(d):l:P(m)})}async function u(s,l,r="Project updated.",f="Changed elsewhere. Reload before trying again."){let p=t.snapshot();if(p.busy||p.loading||p.stale)return;let x=n;t.set({busy:!0,notice:null});let b=await s();if(b.ok&&e.onProjectsChanged?.(),x===n)return t.set({busy:!1}),X(e,b)?t.set({stale:!0,notice:"Complete reauthentication and confirm the pending action."}):b.ok?await h(l?{...p.query,project:l}:p.query,l?S:r):t.set({stale:b.status===412,notice:b.status===412?f:P(b)}),b}return{snapshot:t.snapshot,subscribe:t.subscribe,load:h,async create(s){if(R(t.snapshot()).create)return u(()=>a.request("post","/_pb/projects",{body:s,idempotencyKey:crypto.randomUUID()}),void 0,"Project created.")},async update(s){let l=t.snapshot();if(R(l).settings)return u(()=>a.request("patch","/_pb/projects/{project}",{params:{project:l.selected.slug},headers:{"If-Match":l.etag},body:s}),void 0,"Access policy saved. Existing tokens now use this limit.","This project changed while you were editing. Reload the latest settings before saving.")},async transition(){let s=t.snapshot();R(s).transition&&await u(()=>a.request("post",s.selected.status==="active"?"/_pb/projects/{project}/archive":"/_pb/projects/{project}/restore",{params:{project:s.selected.slug},headers:{"If-Match":s.etag},idempotencyKey:crypto.randomUUID()}),s.selected.status==="active"?s.selected.slug:void 0)},async transitionItem(s){let l=t.snapshot(),r=l.items.find(f=>f.id===s);!r?.etag||!R(l).transitionItems||await u(()=>a.request("post",r.status==="active"?"/_pb/projects/{project}/archive":"/_pb/projects/{project}/restore",{params:{project:r.slug},headers:{"If-Match":r.etag},idempotencyKey:crypto.randomUUID()}),r.status==="active"?r.slug:void 0)},async replayed(s){let l=t.snapshot().query.project,r=l===null?null:`/_pb/projects/${encodeURIComponent(l)}`,f=/^\/_pb\/projects\/[^/]+\/(?:archive|restore)$/.test(s.path);if(!(!f&&s.path!=="/_pb/projects"&&(r===null||![r,`${r}/archive`,`${r}/restore`].includes(s.path))))if(s.ok){let p=f&&s.path.endsWith("/archive")?decodeURIComponent(s.path.split("/")[3]):null;await h(p?{...t.snapshot().query,project:p}:t.snapshot().query,p?S:s.path==="/_pb/projects"?"Project created.":s.path===r?"Access policy saved. Existing tokens now use this limit.":"Project updated.")}else t.set({stale:!0,notice:s.path===r&&s.status===412?"This project changed while you were editing. Reload the latest settings before saving.":P(s)})},dispose(){++n}}}function me({state:e,controller:t}){let n=R(e);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("p",{role:"status",className:"sr-only",children:e.notice}),(0,i.jsx)(ee,{...e,reload:()=>{t.load(e.query)}}),e.query.q?(0,i.jsx)("p",{children:"Filtering loaded projects on this page."}):null,!e.loading&&!e.listError?n.items.length?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("p",{className:"my-3 text-sm text-neutral-600",children:[n.items.length," projects on this page"]}),(0,i.jsx)(Y,{label:"Projects",items:n.items,selectedId:e.selected?.id??"",columns:[{key:"name",label:"Name",value:a=>a.name,render:a=>(0,i.jsxs)("div",{className:"grid gap-1",children:[(0,i.jsx)("a",{className:"font-medium underline",href:C({...e.query,project:a.slug}),children:a.name}),(0,i.jsx)("code",{className:"text-xs text-neutral-600",children:a.slug})]})},{key:"status",label:"Status",value:a=>a.status,render:a=>(0,i.jsx)(J,{status:a.status})},{key:"id",label:"Project ID",value:a=>a.id,render:a=>(0,i.jsx)(G,{value:a.id,label:"project ID"}),priority:3},{key:"actions",label:"Actions",value:()=>"",sortable:!1,render:a=>(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)("a",{className:"underline",href:C({...e.query,project:a.slug}),children:"Open settings"}),(0,i.jsx)("a",{className:"underline",href:q("notifications",{project:a.slug}),children:"Notifications"}),n.transitionItems&&a.etag?a.status==="active"?(0,i.jsx)(D,{action:"Archive",target:`${a.name} (${a.id})`,scope:`Project: ${a.slug}`,description:"Archiving keeps project history and blocks new publishes. You can restore this project later.",disabled:e.busy,onConfirm:()=>{t.transitionItem(a.id)}},`${a.id}:${a.etag}`):(0,i.jsx)($,{type:"button",size:"sm",variant:"outline",disabled:e.busy,onClick:()=>{t.transitionItem(a.id)},children:"Restore"}):null]})}]})]}):(0,i.jsx)(V,{kind:e.query.q||e.query.status?"filtered-empty":"empty",title:"No projects found on this page."}):null,e.next?(0,i.jsx)("a",{className:"my-4 inline-block underline",href:C({...e.query,after:e.next}),children:"Next projects"}):null,e.organization.includes("org:projects:create")&&!e.loading?(0,i.jsxs)("details",{className:"detail-group my-6",children:[(0,i.jsx)("summary",{className:"cursor-pointer font-semibold",children:"New project"}),(0,i.jsx)(F,{disabled:!n.create||e.busy,submit:a=>t.create({...a,slug:a.slug??""})})]}):null,e.selected?(0,i.jsxs)("section",{className:"detail-group my-6 grid gap-3","aria-label":"Project settings",children:[(0,i.jsxs)("h2",{className:"text-lg font-semibold",children:["Settings: ",e.selected.name]}),e.permissions.includes("project:settings:write")&&e.selected.status==="active"?(0,i.jsx)(F,{project:e.selected,disabled:!n.settings||e.busy,submit:t.update},`${e.selected.id}-${e.etag}`):e.selected.requirePublishApproval?(0,i.jsx)("p",{className:"text-sm text-neutral-600",children:"Publish approval is saved as required, but approval is not enforced in this version."}):null,n.transition?e.selected.status==="active"?(0,i.jsx)(D,{action:"Archive",target:e.selected.name,scope:`Project: ${e.selected.slug}`,description:"Archiving keeps project history and blocks new publishes. You can restore this project later.",disabled:e.busy,onConfirm:()=>{t.transition()}},`${e.selected.id}:${e.etag}`):(0,i.jsx)($,{type:"button",variant:"outline",disabled:e.busy,onClick:()=>{t.transition()},children:"Restore"}):null]}):null]})}function Re(){let e=W(),t=(0,E.useMemo)(()=>de(e),[e]),n=(0,E.useSyncExternalStore)(t.subscribe,t.snapshot,t.snapshot),a=se(e,t,O,"projects");return(0,E.useEffect)(()=>{if(n.loading||n.notice!==S||n.query.project!==null)return;let h=C(n.query);window.location.hash!==h&&(window.history.replaceState(null,"",h),window.dispatchEvent(new HashChangeEvent("hashchange")))},[n.loading,n.notice,n.query]),(0,i.jsxs)("section",{"aria-labelledby":"page-heading",children:[(0,i.jsx)("h1",{tabIndex:-1,id:"page-heading",className:"text-xl font-semibold",children:"Projects"}),(0,i.jsx)("p",{className:"mt-1 text-neutral-600",children:"Scopes for sources, packages and tokens. Archiving keeps history and blocks new publishes."}),(0,i.jsx)(te,{route:"projects",query:O(a),statuses:_},a),(0,i.jsx)(me,{state:n,controller:t})]})}export{Re as ProjectsPage,me as ProjectsView,C as buildProjectsHash,de as createProjectsController,O as parseProjectsHash,R as projectsViewModel};
@@ -0,0 +1 @@
1
+ var R={brand:"PACKAGE.broker",description:"open-source package registry broker",version:"2.0.0-rc.4",links:[{label:"AGPL-3.0",href:"https://github.com/package-broker/broker/blob/main/LICENSE"},{label:"Source code",href:"https://github.com/package-broker/broker"},{label:"Documentation",href:"https://package.broker/docs/"}]};function W(e){return e("footer",{className:"product-footer"},e("span",{},e("strong",{},R.brand),` ${R.description}`),e("span",{},`Version ${R.version}`),...R.links.map(({label:t,href:o})=>e("a",{href:o,target:"_blank",rel:"noopener noreferrer","aria-label":`${t} (opens externally in a new tab)`},t)))}function H(){return W((e,t,...o)=>{let r=document.createElement(e);for(let[a,u]of Object.entries(t))r.setAttribute(a==="className"?"class":a,u);return r.append(...o),r})}var F=[10,16,26,18,24,16,18,22,22,26,30,22,22,24],U=[1,1,1,2,2,4,4,4,5,5,5,8,9,9],Y=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66]],J=[236,17],Z=21522,ee=1335,te=7973,j=8;function D(e){let t=(16*e+128)*e+64;if(e>=2){let o=Math.floor(e/7)+2;t-=(25*o-10)*o-55,e>=7&&(t-=36)}return t}function A(e){let t=e-1;return Math.floor(D(e)/8)-F[t]*U[t]}function K(e){return e<=9?8:16}function G(e){if(!Number.isInteger(e)||e<1||e>14)throw new RangeError("unsupported QR version");return Math.floor((A(e)*8-4-K(e))/8)}var Q=G(14),x=new Uint8Array(512),L=new Uint8Array(256);{let e=1;for(let t=0;t<255;t+=1)x[t]=e,L[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t+=1)x[t]=x[t-255]}function P(e,t){return e===0||t===0?0:x[L[e]+L[t]]}function ne(e,t){let o=[1];for(let a=0;a<t;a+=1){let u=new Array(o.length+1).fill(0);for(let s=0;s<o.length;s+=1)u[s]=u[s]^P(o[s],1),u[s+1]=u[s+1]^P(o[s],x[a]);o=u}let r=new Array(t).fill(0);for(let a of e){let u=a^r.shift();r.push(0);for(let s=0;s<t;s+=1)r[s]=r[s]^P(o[s+1],u)}return r}function oe(e,t){let o=[],r=(n,l)=>{for(let i=l-1;i>=0;i-=1)o.push(n>>>i&1)};r(4,4),r(t.length,K(e));for(let n of t)r(n,8);let a=A(e)*8;r(0,Math.min(4,a-o.length)),r(0,(8-o.length%8)%8);let u=[];for(let n=0;n<o.length;n+=8)u.push(parseInt(o.slice(n,n+8).join(""),2));for(let n=0;u.length<A(e);n+=1)u.push(J[n%2]);let s=e-1,f=U[s],w=F[s],b=Math.floor(D(e)/8),m=f-b%f,h=Math.floor(b/f)-w,g=[],k=[],c=0;for(let n=0;n<f;n+=1){let l=h+(n<m?0:1),i=u.slice(c,c+l);c+=l,g.push(i),k.push(ne(i,w))}let d=[];for(let n=0;n<h+1;n+=1)for(let l of g)n<l.length&&d.push(l[n]);for(let n=0;n<w;n+=1)for(let l of k)d.push(l[n]);return d}function B(e,t,o){let r=e;for(let a=0;a<o;a+=1)r=r<<1^(r>>>o-1)*t;return r}function re(e,t,o){switch(e){case 0:return(t+o)%2===0;case 1:return o%2===0;case 2:return t%3===0;case 3:return(t+o)%3===0;case 4:return(Math.floor(t/3)+Math.floor(o/2))%2===0;case 5:return t*o%2+t*o%3===0;case 6:return(t*o%2+t*o%3)%2===0;default:return((t+o)%2+t*o%3)%2===0}}function q(e){let t=0,o=1;for(let a=1;a<=e.length;a+=1){if(a<e.length&&e[a]===e[a-1]){o+=1;continue}o>=5&&(t+=3+(o-5)),o=1}let r=`0000${e.map(a=>a?"1":"0").join("")}0000`;for(let a=0;a+11<=r.length;a+=1){let u=r.slice(a,a+11);(u==="10111010000"||u==="00001011101")&&(t+=40)}return t}function se(e){let t=e.length,o=0,r=0;for(let u=0;u<t;u+=1){let s=e[u];o+=q(s),o+=q(e.map(f=>f[u]));for(let f=0;f<t;f+=1)s[f]&&(r+=1),f+1<t&&u+1<t&&s[f]===s[f+1]&&s[f]===e[u+1][f]&&s[f]===e[u+1][f+1]&&(o+=3)}let a=t*t;return o+=(Math.ceil(Math.abs(r*20-a*10)/a)-1)*10,o}function ae(e,t,o){let r=e*4+17,a=Array.from({length:r},()=>new Array(r).fill(!1)),u=Array.from({length:r},()=>new Array(r).fill(!1)),s=(c,d,n)=>{a[d][c]=n,u[d][c]=!0};for(let c=0;c<r;c+=1)s(6,c,c%2===0),s(c,6,c%2===0);let f=(c,d)=>{for(let n=-4;n<=4;n+=1)for(let l=-4;l<=4;l+=1){let i=Math.max(Math.abs(l),Math.abs(n)),y=c+l,_=d+n;y>=0&&y<r&&_>=0&&_<r&&s(y,_,i!==2&&i!==4)}};f(3,3),f(r-4,3),f(3,r-4);let w=Y[e-1],b=w.length-1;w.forEach((c,d)=>{w.forEach((n,l)=>{if(!(d===0&&l===0||d===0&&l===b||d===b&&l===0))for(let i=-2;i<=2;i+=1)for(let y=-2;y<=2;y+=1)s(n+y,c+i,Math.max(Math.abs(y),Math.abs(i))!==1)})});let m=c=>{let d=c,n=(d<<10|B(d,ee,10))^Z,l=i=>(n>>>i&1)!==0;for(let i=0;i<=5;i+=1)s(8,i,l(i));s(8,7,l(6)),s(8,8,l(7)),s(7,8,l(8));for(let i=9;i<15;i+=1)s(14-i,8,l(i));for(let i=0;i<8;i+=1)s(r-1-i,8,l(i));for(let i=8;i<15;i+=1)s(8,r-15+i,l(i));s(8,r-8,!0)};if(m(0),e>=7){let c=e<<12|B(e,te,12);for(let d=0;d<18;d+=1){let n=(c>>>d&1)!==0,l=r-11+d%3,i=Math.floor(d/3);s(l,i,n),s(i,l,n)}}let h=0;for(let c=r-1;c>=1;c-=2){c===6&&(c=5);for(let d=0;d<r;d+=1)for(let n=0;n<2;n+=1){let l=c-n,y=(c+1&2)===0?r-1-d:d;!u[y][l]&&h<t.length*8&&(a[y][l]=(t[h>>>3]>>>7-(h&7)&1)!==0,h+=1)}}let g=c=>a.map((d,n)=>d.map((l,i)=>!u[n][i]&&re(c,i,n)?!l:l)),k=o??0;if(o===void 0){let c=1/0;for(let d=0;d<j;d+=1){m(d);let n=se(g(d));n<c&&(c=n,k=d)}}return m(k),{version:e,size:r,mask:k,modules:g(k)}}function V(e,t={}){let{mask:o}=t;if(o!==void 0&&(!Number.isInteger(o)||o<0||o>=j))throw new RangeError("unsupported QR mask");if(typeof e!="string"||e.length===0)throw new TypeError("QR text is empty");if(e.length>Q)throw new RangeError("QR text is too long");let r=new TextEncoder().encode(e);if(r.length>Q)throw new RangeError("QR text is too long");let a=1;for(;G(a)<r.length;)a+=1;return ae(a,oe(a,r),o)}var v="/_pb/ui/";var ie="/_pb/auth/local/setup/start",le="/_pb/auth/local/setup/finish",ue=43,X=1024,ce=["too_short","too_long","equals_email","not_well_formed"];function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function de(e){if(!T(e)||!T(e.error))return null;let t=e.error;if(t.code!=="weak_password"||!Array.isArray(t.problems))return null;let o=t.problems.filter(r=>typeof r=="string"&&ce.includes(r));return o.length>0?o:null}function pe(e){try{return V(e)}catch{return null}}function fe(e){let{transport:t}=e,o=new Set,r=null,a={stage:"checking",busy:!1,notice:null,problems:[],enrollment:null},u=!1,s=b=>{if(!u){a={...a,...b};for(let m of[...o])m()}},f=()=>{r=null},w=async(b,m)=>{try{return await t.post(b,m)}catch{return null}};return t.get("/_pb/auth/providers").then(b=>{if(u)return;let m=b.json;s({stage:b.status===200&&T(m)&&typeof m.local=="boolean"?m.local?"token":"disabled":"unavailable"})},()=>s({stage:"unavailable"})),{snapshot:()=>a,subscribe(b){return o.add(b),()=>{o.delete(b)}},async submitToken(b){if(a.busy||a.stage!=="token")return;let m=b.trim();if(m.length!==ue||!/^[A-Za-z0-9_-]+$/.test(m)){s({notice:"bad_token_shape"});return}s({busy:!0,notice:null});let h=await w(ie,{token:m});if(h===null){s({busy:!1,notice:"unavailable"});return}if($(h)){f(),s({busy:!1,stage:"disabled",notice:null,enrollment:null,problems:[]});return}if(h.status===200){let g=h.json;if(T(g)&&typeof g.provisioningUri=="string"&&typeof g.secret=="string"&&g.secret.length>0){r=m;let k=pe(g.provisioningUri);s({busy:!1,stage:"enroll",notice:k===null?"qr_unavailable":null,enrollment:{provisioningUri:g.provisioningUri,secret:g.secret,qr:k}});return}s({busy:!1,notice:"unavailable"});return}s({busy:!1,notice:me(h.status)})},async finish(b){if(a.busy||a.stage!=="enroll"||r===null)return;let{password:m,confirmation:h,code:g}=b,k=g.replace(/\s+/g,"");if(m.length===0||k.length===0){s({notice:"missing_fields",problems:[]});return}if(m.length>X||k.length>X||m!==h){s({notice:"password_mismatch",problems:[]});return}s({busy:!0,notice:null,problems:[]});let c=await w(le,{token:r,password:m,code:k});if(c===null||c.status>=500){f(),s({busy:!1,stage:"uncertain",notice:null,enrollment:null});return}if($(c)){f(),s({busy:!1,stage:"disabled",notice:null,enrollment:null,problems:[]});return}if(c.status===204){f(),s({busy:!1,stage:"done",notice:null,enrollment:null});return}let d=c.status===400?de(c.json):null;if(d!==null){s({busy:!1,notice:"weak_password",problems:d});return}if(c.status===403){s({busy:!1,notice:"origin_refused"});return}if(c.status===429){s({busy:!1,notice:"rate_limited"});return}s({busy:!1,notice:"finish_refused"})},dispose(){f(),u=!0,a={...a,enrollment:null,problems:[],busy:!1},o.clear()}}}function $(e){let t=e.json;return e.status===403&&T(t)&&T(t.error)&&t.error.code==="local_auth_disabled"}function me(e){return e===401||e===400?"token_refused":e===403?"origin_refused":e===429?"rate_limited":"unavailable"}function be(e,t){return{async get(o){let r=await e(o,{credentials:"same-origin",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",...t===void 0?{}:{signal:t}});return{status:r.status,json:await r.json().catch(()=>null)}},async post(o,r){let a=await e(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r),credentials:"same-origin",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",...t===void 0?{}:{signal:t}}),u=await a.json().catch(()=>null);return{status:a.status,json:u}}}}var he={bad_token_shape:"That does not look like a setup token. Paste the whole token exactly as it was issued.",token_refused:"This setup token was not accepted. It may be wrong, expired or already used. Ask the person who runs the broker for a fresh token.",origin_refused:"The broker refused this request because it came from a different address.",rate_limited:"Too many attempts. Wait a few minutes and try again.",unavailable:"The broker could not be reached or answered unexpectedly. Try again in a moment.",password_mismatch:"The password and its confirmation do not match.",missing_fields:"Enter a password and the six digit code from your authenticator.",weak_password:"The password does not meet the requirements.",finish_refused:"Setup was not completed. Check the six digit code and try again. If it keeps failing, ask for a fresh setup token.",qr_unavailable:"The QR code could not be drawn. Enter the setup key below in your authenticator instead."},ge={too_short:"The password is too short.",too_long:"The password is too long.",equals_email:"The password must not be the same as the account e-mail address.",not_well_formed:"The password contains characters that are not allowed."},S=6,N=4;function ye(e,t){let o=t.size+N*2;e.width=o*S,e.height=o*S;let r=e.getContext("2d");r!==null&&(r.fillStyle="#ffffff",r.fillRect(0,0,e.width,e.height),r.fillStyle="#000000",t.modules.forEach((a,u)=>{a.forEach((s,f)=>{s&&r.fillRect((f+N)*S,(u+N)*S,S,S)})}))}function p(e,t={},...o){let r=document.createElement(e);for(let[a,u]of Object.entries(t))r.setAttribute(a,u);for(let a of o)r.append(a);return r}var we="mt-1 block w-full rounded border border-gray-400 px-3 py-2 text-base focus:outline-none focus:ring-2 focus:ring-blue-600",O="rounded bg-blue-700 px-4 py-2 text-base font-medium text-white hover:bg-blue-800 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 disabled:opacity-60";function M(e,t,o,r){let a=p("input",{id:e,name:e,class:we,autocapitalize:"off",spellcheck:"false",required:"",...r===void 0?{}:{"aria-describedby":`${e}-hint`},...o});return{wrapper:p("div",{class:"mt-4"},p("label",{for:e,class:"block text-sm font-medium"},t),...r===void 0?[]:[p("p",{id:`${e}-hint`,class:"mt-1 text-sm text-gray-700"},r)],a),input:a}}function ke(e,t){let o=fe({transport:t.transport}),r=null,a={},u=null,s=null,f=null,w=n=>p("h1",{class:"text-2xl font-semibold",tabindex:"-1",id:"setup-heading"},n),b=()=>{for(let n of Object.values(a))n.value="";a={}},m=()=>{let n=M("setup-token","Setup token",{type:"password",autocomplete:"off","aria-describedby":"setup-token-hint"}),l=p("p",{id:"setup-token-hint",class:"mt-1 text-sm text-gray-700"},"Paste the one-time token printed by the command that created your administrator account. It is never put in the address bar.");n.wrapper.insertBefore(l,n.input),a={token:n.input},f=p("button",{type:"submit",class:O},"Continue");let i=p("form",{id:"token-form",novalidate:"","aria-labelledby":"setup-heading"},n.wrapper,p("div",{class:"mt-6"},f));return i.addEventListener("submit",y=>{y.preventDefault(),o.submitToken(n.input.value)}),p("section",{},w("Set up the administrator account"),p("p",{class:"mt-2 text-gray-700"},"Step 1 of 2. Enter your setup token. You will then choose a password and connect an authenticator app."),i)},h=n=>{let l=n.enrollment,i=M("setup-password","Password",{type:"password",autocomplete:"new-password"}),y=M("setup-password-confirm","Confirm password",{type:"password",autocomplete:"new-password"}),_=M("setup-code","Six digit code from your authenticator",{type:"text",inputmode:"numeric",autocomplete:"one-time-code",pattern:"[0-9 ]*"});a={password:i.input,confirmation:y.input,code:_.input};let I=p("div",{class:"mt-4"});if(l?.qr){let E=p("canvas",{id:"setup-qr",role:"img","aria-label":"QR code for your authenticator app. If you cannot scan it, use the setup key below.",class:"h-auto max-w-full rounded border border-gray-400 [image-rendering:pixelated]"});ye(E,l.qr),I.append(E)}let z=p("div",{class:"mt-4"},p("p",{class:"text-sm font-medium",id:"setup-secret-label"},"Setup key (enter manually)"),p("code",{id:"setup-secret","aria-labelledby":"setup-secret-label",class:"mt-1 block break-all rounded bg-gray-100 px-3 py-2 font-mono text-base"},l?.secret??""),p("p",{class:"mt-1 text-sm text-gray-700"},"Type: time based, 6 digits, 30 seconds, SHA-1."));f=p("button",{type:"submit",class:O},"Finish setup");let C=p("form",{id:"finish-form",novalidate:"","aria-labelledby":"setup-heading"},i.wrapper,y.wrapper,_.wrapper,p("div",{class:"mt-6"},f));return C.addEventListener("submit",E=>{E.preventDefault(),o.finish({password:i.input.value,confirmation:y.input.value,code:_.input.value})}),p("section",{},w("Connect your authenticator"),p("p",{class:"mt-2 text-gray-700"},"Step 2 of 2. Scan the QR code with an authenticator app, or enter the setup key by hand. Then choose a password and enter the current code."),I,z,C)},g=()=>{let n=p("button",{type:"button",id:"open-app",class:O},"Open Package Broker");return n.addEventListener("click",()=>{t.navigate(v)}),p("section",{},w("Setup complete"),p("p",{class:"mt-2 text-gray-700"},"Your administrator account is ready and you are signed in. From now on sign in with your e-mail address, your password and a code from your authenticator."),p("div",{class:"mt-6"},n))},k=()=>p("section",{},w("Setup may or may not have finished"),p("p",{class:"mt-2 text-gray-700"},"The broker did not give a clear answer. Nothing was retried. Keep your authenticator enrollment and the password you chose. The broker currently accepts sign-in through its HTTP API. If sign-in fails, ask for a fresh setup token and start again."),p("p",{class:"mt-4 text-gray-700"},"From a trusted HTTP client, send POST /_pb/auth/local/login to this broker with Content-Type: application/json and an Origin header equal to the broker address. Supply JSON fields email (your administrator e-mail address), password (the password you just chose), and code (a fresh six digit authenticator code). Read credentials from a protected file or private prompt, rather than command-line arguments. Save the response to a protected file and session cookies to a protected cookie jar; do not print either. A 204 response means you are signed in for subsequent requests using that cookie jar in the same client. See docs/workers-install.md for curl instructions and cleanup.")),c=()=>{let n=o.snapshot();if(r!==n.stage){b(),e.replaceChildren();let l=n.stage==="checking"||n.stage==="disabled"||n.stage==="unavailable"?p("section",{},w("Set up the administrator account"),...n.stage==="checking"?[]:[p("h2",{class:"mt-4 font-semibold"},n.stage==="disabled"?"Sign in with your organization's account":"Setup is unavailable")],p("p",{role:n.stage==="unavailable"?"alert":"status",class:"mt-2 text-gray-700"},n.stage==="checking"?"Checking sign-in options\u2026":n.stage==="disabled"?"Password setup is unavailable. Sign in to continue, or contact your administrator for help.":"Sign-in options could not be loaded. Reload the page to try again."),p("a",{href:`${v}#/login`,class:"mt-4 block text-blue-700 underline"},"Go to sign in")):n.stage==="token"?m():n.stage==="enroll"?h(n):n.stage==="done"?g():k();s=p("div",{id:"setup-notice",role:"alert",class:"mt-4 text-red-800"}),u=p("p",{id:"setup-status",role:"status",class:"mt-4 text-gray-700"});let i=p("main",{class:"mx-auto w-full max-w-xl flex-1 p-6"},l,s,u);e.className="flex min-h-screen flex-col",e.append(i,H()),document.getElementById("setup-heading")?.focus(),r=n.stage}f&&(f.disabled=n.busy),u&&(u.textContent=n.busy?"Working\u2026":""),s&&(s.replaceChildren(),n.notice!==null&&(s.append(p("p",{},he[n.notice])),n.notice==="weak_password"&&s.append(p("ul",{class:"mt-1 list-disc pl-6"},...n.problems.map(l=>p("li",{},ge[l]))))))},d=o.subscribe(c);return c(),()=>{d(),b(),o.dispose(),e.replaceChildren()}}if(typeof document<"u"){let e=document.getElementById("root");if(e!==null){let t=ke(e,{transport:be(fetch.bind(globalThis)),navigate:o=>{window.location.assign(o)}});window.addEventListener("pagehide",t,{once:!0}),window.addEventListener("pageshow",o=>{o.persisted&&window.location.reload()})}}export{v as APP_PATH,he as NOTICE_TEXT,ge as PROBLEM_TEXT,le as SETUP_FINISH_PATH,ie as SETUP_START_PATH,be as createFetchTransport,fe as createSetupController,ke as mountSetup};
@@ -5,10 +5,10 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <meta name="referrer" content="no-referrer" />
7
7
  <title>Package Broker setup</title>
8
- <link rel="stylesheet" href="/_pb/ui/setup/assets/app.e8cea8b32d3a.css" />
9
- <script type="module" src="/_pb/ui/setup/assets/setup.98343039898f.js"></script>
8
+ <link rel="stylesheet" href="/_pb/ui/setup/assets/app.45b156168495.css" />
9
+ <script type="module" src="/_pb/ui/setup/assets/setup.8e977608d413.js"></script>
10
10
  </head>
11
11
  <body>
12
- <main id="root" class="mx-auto max-w-xl p-6"></main>
12
+ <div id="root"></div>
13
13
  </body>
14
14
  </html>
@@ -0,0 +1 @@
1
+ import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l}from"./chunk.51497edc7697.js";import"./chunk.675b635d9462.js";import"./chunk.e3b0c44298fc.js";import"./chunk.28a4d8aab337.js";import"./chunk.56d473a1587d.js";import"./chunk.d18497920e4d.js";import"./chunk.8442124f6802.js";import"./chunk.a6d755a9789f.js";import"./chunk.965b76812604.js";import"./chunk.3fcd6998795a.js";import"./chunk.d813fefb410d.js";import"./chunk.741aec8d1ff9.js";import"./chunk.fd375c54b526.js";export{g as CredentialFields,h as SYNC_ERROR_LABELS,i as SourceActions,l as SourcesPage,k as SourcesView,e as createSourcesModel,d as displayUrl,j as filterSources,b as sourceCredentialKind,a as sourceCredentialKinds,f as submitCredential,c as suggestedScopePatterns};
@@ -0,0 +1,4 @@
1
+ import{a as be}from"./chunk.f54ea1378c8c.js";import"./chunk.e3b0c44298fc.js";import{b as je}from"./chunk.28a4d8aab337.js";import{b as ae}from"./chunk.8442124f6802.js";import{a as G}from"./chunk.a6d755a9789f.js";import{a as Q,b as ve,c as F}from"./chunk.965b76812604.js";import"./chunk.3fcd6998795a.js";import{a as X}from"./chunk.d813fefb410d.js";import{a as L}from"./chunk.741aec8d1ff9.js";import{D as ne,E as U,F as D,K as ye,c as B,d as te,g as H,h as me,i as ge,m as fe,n as he,p as C}from"./chunk.fd375c54b526.js";var re=()=>({packageName:"",repository:"",workflow:"",environment:"",refPattern:""});function ke(e){let t={items:[],next:null,hasPrevious:!1,draft:re(),editing:null,loading:!1,loadError:!1,busy:!1,stale:!1,editDisabled:!1,notice:null},n=0,u=[void 0],a=new Set,p=f=>{t={...t,...f};for(let i of a)i()},k=f=>{let i=f.code==="conflict"||f.status===412||f.status===428;p({stale:i,notice:i?"This publisher changed. Reload the latest settings and review your draft before saving.":f.code==="github_credentials_required"?"Configure a GitHub source for this repository with a GitHub App installation or token first.":f.code==="ambiguous_trusted_publisher"?"A publisher already uses this package, repository, workflow and environment.":f.code==="name_not_claimed"?"Claim this package on an active hosted npm source first.":"The publisher could not be saved. Check your settings and try again."})},s={snapshot:()=>t,subscribe(f){return a.add(f),()=>{a.delete(f)}},draft(f){p({draft:f})},edit(f){p({draft:{packageName:f.packageName,repository:f.repository,workflow:f.workflow,environment:f.environment,refPattern:f.refPattern??""},editing:{id:f.id,revision:f.revision},notice:null,editDisabled:!1})},cancel(){p({draft:re(),editing:null,notice:null,editDisabled:!1})},clear(){n++,u=[void 0],p({draft:re(),editing:null,items:[],next:null,hasPrevious:!1,notice:null,busy:!1,loading:!1,stale:!1,editDisabled:!1,loadError:!1})},async load(){if(t.busy)return;let f=++n;p({loading:!0,loadError:!1});let i=u[u.length-1],x=await e.client.request("get","/_pb/trusted-publishers",{query:i===void 0?{}:{cursor:i}});if(f!==n)return;if(!x.ok){p({loading:!1,loadError:!0});return}let S=t.editing,N=!1;if(S!==null){let I=x.data.items.find(o=>o.id===S.id&&o.disabledAt===null);N=I===void 0,I!==void 0&&(S={id:I.id,revision:I.revision})}p({items:x.data.items,next:x.data.next??null,hasPrevious:u.length>1,loading:!1,stale:!1,editing:S,editDisabled:N,notice:N?"This publisher was disabled or is no longer available. Cancel this edit to create a new publisher.":t.stale?"Latest settings loaded. Review your draft before saving again.":t.notice})},async nextPage(){t.busy||t.loading||t.stale||t.loadError||t.editing!==null||t.next===null||(u.push(t.next),await s.load())},async previousPage(){t.busy||t.loading||t.stale||t.loadError||t.editing!==null||u.length<2||(u.pop(),await s.load())},async save(){if(t.busy||t.loading||t.stale||t.loadError||t.editDisabled)return;let f=n;p({busy:!0,notice:null});let{draft:i,editing:x}=t,S={packageName:i.packageName,repository:i.repository,workflow:i.workflow,environment:i.environment,...i.refPattern===""?{}:{refPattern:i.refPattern}},N=x===null?await e.client.request("post","/_pb/trusted-publishers",{body:S}):await e.client.request("put","/_pb/trusted-publishers/{id}",{params:{id:x.id},headers:{"If-Match":`"r${x.revision}"`},body:S});if(f===n){if(p({busy:!1}),!N.ok){k(N);return}p({draft:re(),editing:null,notice:"Trusted publisher saved."}),await s.load()}},async disable(f){if(t.busy||t.loading||t.stale||t.loadError)return;let i=n;p({busy:!0,notice:null});let x=await e.client.request("delete","/_pb/trusted-publishers/{id}",{params:{id:f.id},headers:{"If-Match":`"r${f.revision}"`}});if(i===n){if(p({busy:!1}),!x.ok){k(x);return}p({notice:"Publisher disabled. Its workload tokens have been revoked."}),await s.load()}}};return s}var R=B(te(),1);var j=B(H(),1),_e=e=>(window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)),$e=()=>window.location.hash,qe=()=>"";function we({controller:e,permissions:t}){let n=(0,R.useSyncExternalStore)(e.subscribe,e.snapshot,e.snapshot),u=(0,R.useSyncExternalStore)(_e,$e,qe),a=new URLSearchParams(u.split("?")[1]??"").get("section")==="trusted-publishers",[p,k]=(0,R.useState)(a||n.editing!==null),[s,f]=(0,R.useState)(!1),[i,x]=(0,R.useState)(!1),S=(0,R.useRef)(null),N=(0,R.useRef)(null),I=s||n.editing!==null,o=n.busy||n.loading||n.stale||n.loadError;(0,R.useEffect)(()=>{(a||n.editing!==null)&&k(!0)},[a,n.editing]),(0,R.useEffect)(()=>{p&&I&&document.getElementById("publisher-packageName")?.focus()},[p,I,n.editing?.id]),(0,R.useEffect)(()=>{if(!i||I||o)return;(N.current?.isConnected?N.current:S.current)?.focus(),x(!1)},[i,I,o]);let h=t.includes("org:service-principals:write"),m=h&&t.includes("org:packages:publish");if((0,R.useEffect)(()=>(h&&e.load(),()=>e.clear()),[e,h]),!h)return null;let w=l=>{l.preventDefault(),e.save().then(()=>{e.snapshot().notice==="Trusted publisher saved."&&(f(!1),x(!0))})};return(0,j.jsxs)("details",{id:"trusted-publishers",className:"detail-group space-y-4",open:p,onToggle:l=>k(l.currentTarget.open),children:[(0,j.jsx)("summary",{className:"min-h-11 cursor-pointer font-semibold",children:"Trusted publishers"}),(0,j.jsx)("p",{children:"Organization \xB7 Let a GitHub Actions workflow publish one claimed npm package using short-lived credentials."}),(0,j.jsx)("p",{children:"Configure an organization GitHub source for the repository with a GitHub App installation or token so its numeric identity can be verified."}),n.notice===null?null:(0,j.jsx)("p",{role:"status",children:n.notice}),m&&!I?(0,j.jsx)(C,{ref:S,type:"button",className:"min-h-11",disabled:o,onClick:l=>{N.current=l.currentTarget,f(!0)},children:"Add trusted publisher"}):null,(0,j.jsx)(C,{type:"button",variant:"outline",className:"min-h-11",disabled:n.busy||n.loading,onClick:()=>{e.load()},children:"Reload trusted publishers"}),n.loading?(0,j.jsx)(F,{kind:"loading",title:"Loading trusted publishers\u2026"}):n.loadError?(0,j.jsx)(F,{kind:"error",title:"Trusted publishers could not be loaded."}):n.items.length===0?(0,j.jsx)(F,{kind:"empty",title:n.hasPrevious?"No trusted publishers on this page.":"No trusted publishers yet."}):(0,j.jsx)(Q,{label:"Organization trusted publishers",items:n.items,columns:[{key:"package",label:"Package",value:l=>l.packageName,render:l=>(0,j.jsx)("strong",{className:"break-all",children:l.packageName})},{key:"workflow",label:"GitHub workflow",value:l=>l.repository,render:l=>(0,j.jsxs)("div",{className:"break-all",children:[(0,j.jsx)("p",{children:l.repository}),(0,j.jsx)("p",{children:l.workflow})]})},{key:"binding",label:"Conditions",value:l=>l.environment,render:l=>(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)("p",{children:["Environment: ",l.environment||"No environment"]}),(0,j.jsxs)("p",{children:["Ref: ",l.refPattern??"Any ref"]}),(0,j.jsx)("p",{children:l.disabledAt===null?"Enabled":"Disabled"})]})},{key:"used",label:"Last used",value:l=>l.lastUsedAt??"",render:l=>l.lastUsedAt===null?"Never used":(0,j.jsx)(X,{value:l.lastUsedAt})},{key:"actions",label:"Actions",value:()=>"",sortable:!1,render:l=>!m||l.disabledAt!==null?null:(0,j.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,j.jsx)(C,{type:"button",className:"min-h-11",variant:"outline",disabled:o,onClick:v=>{N.current=v.currentTarget,f(!1),e.edit(l)},children:"Edit publisher"}),(0,j.jsx)(G,{action:"Disable publisher",target:`${l.packageName}: ${l.repository} / ${l.workflow}`,scope:"Organization",description:"This workflow will no longer be able to publish through this binding. Its workload tokens will be revoked immediately. The binding remains in the history and cannot be recreated.",disabled:o,onConfirm:()=>{e.disable(l)}})]})}]}),(0,j.jsxs)("p",{children:[n.items.length," trusted publishers on this page"]}),(0,j.jsxs)("div",{className:"flex gap-2",children:[(0,j.jsx)(C,{type:"button",className:"min-h-11",variant:"outline",disabled:o||I||!n.hasPrevious,onClick:()=>{e.previousPage()},children:"Previous publishers"}),(0,j.jsx)(C,{type:"button",className:"min-h-11",variant:"outline",disabled:o||I||n.next===null,onClick:()=>{e.nextPage()},children:"Next publishers"})]}),m?I?(0,j.jsxs)("form",{onSubmit:w,className:"grid max-w-5xl items-start gap-x-6 gap-y-4 lg:grid-cols-2","aria-label":n.editing===null?"New trusted publisher":"Edit trusted publisher",children:[(0,j.jsx)("h3",{className:"lg:col-span-2 font-semibold",children:n.editing===null?"New trusted publisher":"Edit trusted publisher"}),[["packageName","npm package",!0],["repository","GitHub repository (owner/name)",!0],["workflow","Workflow filename",!0],["environment","Environment (optional)",!1],["refPattern","Ref pattern (optional)",!1]].map(([l,v,E])=>(0,j.jsxs)("div",{children:[(0,j.jsx)(D,{htmlFor:`publisher-${l}`,children:v}),(0,j.jsx)(U,{id:`publisher-${l}`,value:n.draft[l],required:E,maxLength:l==="packageName"?214:l==="repository"?140:255,disabled:n.busy,"aria-describedby":l==="refPattern"?"publisher-ref-help":l==="environment"?"publisher-environment-help":void 0,onChange:A=>e.draft({...n.draft,[l]:A.target.value})}),l==="refPattern"?(0,j.jsx)("p",{id:"publisher-ref-help",children:"Use a full ref such as refs/tags/v*. * crosses /, ? matches one character, and matching is case-sensitive. Leave blank to allow any ref."}):l==="environment"?(0,j.jsx)("p",{id:"publisher-environment-help",children:"ASCII letters are matched without case. Leave blank for a workflow job without an environment. A named environment must match."}):null]},l)),(0,j.jsx)("p",{className:"lg:col-span-2",children:"Saving creates or updates an organization service identity with permission to publish this package. Workflow identity is verified against GitHub's numeric repository and owner IDs."}),(0,j.jsxs)("div",{className:"lg:col-span-2 flex flex-wrap gap-2",children:[(0,j.jsx)(C,{type:"submit",className:"min-h-11 w-full sm:w-auto",disabled:o||n.editDisabled,children:n.busy?"Saving publisher\u2026":"Save trusted publisher"}),(0,j.jsx)(C,{type:"button",className:"min-h-11",variant:"outline",disabled:n.busy,onClick:()=>{e.cancel(),f(!1),x(!0)},children:n.editing===null?"Cancel":"Cancel edit"})]})]}):null:(0,j.jsx)("p",{children:"Publishing and service identity management permissions are both required to manage publishers."})]})}var M=B(te(),1);var $=B(te(),1);var _=B(te(),1);var P=B(H(),1),Y={"project:read":["Read project details","View project information."],"project:packages:read":["Install and download packages","Read package metadata and download packages."],"project:packages:write":["Include publish permission","Publishing is not available in this version."],"project:grants:read":["Read project grants","View who has access to this project."],"project:sources:read":["Read project sources","View this project's package sources."],"project:audit:read":["Read project audit records","View recorded changes in this project."],"org:packages:publish":["Include organization publish permission","Include permission to publish packages to the organization. Publishing is not available in this version."],"org:read":["Read organization details","View organization information."],"org:users:read":["Read organization users","Read user information allowed by the API."],"org:roles:read":["Read organization roles","View organization role definitions."],"org:grants:read":["Read organization grants","View organization access rules."],"org:sources:read":["Read organization sources","View organization package sources."],"org:import:write":["Create and read import runs","Plan and inspect imports; cannot approve or apply them."],"org:audit:read":["Read organization audit records","View recorded organization changes."]},se=Object.keys(Y),Z=["project:read","project:packages:read"],Pe=["project:read","project:grants:read","project:sources:read","project:audit:read"];function Ce({state:e,controller:t}){let[n,u]=(0,_.useState)(!1),[a,p]=(0,_.useState)(""),[k,s]=(0,_.useState)(""),[f,i]=(0,_.useState)(Z),[x,S]=(0,_.useState)("Install packages"),[N,I]=(0,_.useState)(""),[o,h]=(0,_.useState)("principal-name"),[m,w]=(0,_.useState)(null),l=e.projects.find(g=>g.id===k),v=k==="organization"?e.organizationPermissions:l?.permissions??[],E=se.filter(g=>k==="organization"||g.startsWith("project:")).map(g=>({name:g,scope:g.startsWith("org:")?"organization":"project",description:Y[g][0]})),A=e.organizationPermissions.includes("org:service-principals:write"),y=e.organizationPermissions.includes("org:settings:write")&&A;return(0,_.useEffect)(()=>{l&&t.loadProjectPolicies([l.id])},[t,l]),(0,_.useEffect)(()=>{!k||l&&l.policyState!=="loaded"||i(g=>(x==="Install packages"?Z:x==="Read project records"?Pe:g).filter(b=>v.includes(b)))},[k,l,x,e.organizationPermissions]),y?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(C,{className:"min-h-11 w-full sm:w-auto",type:"button",onClick:()=>{u(!0),w(null)},children:"New service principal"}),m&&(0,P.jsx)("div",{children:(0,P.jsx)(C,{className:"min-h-11 w-full sm:w-auto",type:"button",onClick:()=>{t.choosePrincipal(m.id,e.projects.find(g=>g.id===m.projectId)?.slug??null,m.projectId===null),w(null),document.getElementById("new-token")?.focus()},children:"Create token"})}),n&&(0,P.jsxs)("form",{noValidate:!0,"aria-label":"New service principal",className:"grid max-w-5xl items-start gap-x-6 gap-y-4 lg:grid-cols-2",onSubmit:g=>{g.preventDefault();let b=a.trim()?k?l?.policyState==="loading"||l?.policyState==="idle"?{target:"principal-project",message:"Project access is still loading."}:l?.policyState==="error"?{target:"principal-project",message:"Project access could not be loaded. Try again."}:f.length?f.every(T=>v.includes(T))?null:{target:"principal-permissions",message:"You cannot grant every selected permission here."}:{target:"principal-permissions",message:"Choose at least one permission."}:{target:"principal-project",message:"Choose a project."}:{target:"principal-name",message:"Enter a service identity name."};if(b){h(b.target),requestAnimationFrame(()=>document.getElementById("principal-errors")?.focus()),I(b.message);return}I(""),t.createPrincipal(a,k==="organization"?"":k,f).then(T=>{T&&(w(T),u(!1),p(""))})},children:[(0,P.jsx)("h2",{className:"lg:col-span-2",children:"New service principal"}),(0,P.jsx)("p",{className:"lg:col-span-2",children:"Create a service identity for automation, then issue a token for it."}),N&&(0,P.jsx)("div",{id:"principal-errors",tabIndex:-1,role:"alert",className:"lg:col-span-2",children:(0,P.jsx)("button",{type:"button",className:"min-h-11 underline",onClick:()=>document.getElementById(o)?.focus(),children:N})}),(0,P.jsxs)("div",{children:[(0,P.jsx)(D,{htmlFor:"principal-name",children:"Service identity name"}),(0,P.jsx)(U,{className:"min-h-11",id:"principal-name","aria-invalid":!!N&&o==="principal-name",value:a,placeholder:"e.g. ci-storefront","aria-describedby":"principal-name-help",onChange:g=>p(g.target.value)}),(0,P.jsx)("p",{id:"principal-name-help",children:"Use one identity for each CI pipeline so you can stop its access separately."})]}),(0,P.jsxs)("div",{children:[(0,P.jsx)(D,{htmlFor:"principal-project",children:"Project"}),(0,P.jsxs)(L,{className:"min-h-11",id:"principal-project","aria-invalid":!!N&&o==="principal-project",value:k,onChange:g=>{let b=g.target.value,T=f.filter(K=>b==="organization"||K.startsWith("project:"));s(b),i(T),T.length!==f.length&&t.announce("Project changed. Incompatible permissions were removed.")},children:[(0,P.jsx)("option",{value:"",children:"Choose a project"}),e.projects.map(g=>(0,P.jsx)("option",{value:g.id,children:g.name},g.id)),(0,P.jsx)("option",{value:"organization",children:"Organization-wide (advanced)"})]}),k==="organization"&&(0,P.jsx)("p",{children:"Can carry permissions across projects and for the organization. Choose a single project for a CI pipeline that only installs its packages."})]}),(0,P.jsxs)("fieldset",{id:"principal-permissions",tabIndex:-1,className:"lg:col-span-2",children:[(0,P.jsx)("legend",{children:"Permissions"}),(0,P.jsx)("div",{className:"flex flex-wrap gap-2",children:["Install packages","Read project records","Custom"].map(g=>(0,P.jsx)(C,{className:"min-h-11 w-full sm:w-auto",type:"button","aria-pressed":x===g,onClick:()=>{S(g),g!=="Custom"&&i((g==="Install packages"?Z:Pe).filter(b=>v.includes(b)))},children:g},g))}),x==="Read project records"&&(0,P.jsx)("p",{children:"To issue an Install and download token, also select Install and download packages."}),l?.policyState==="loading"&&(0,P.jsx)("p",{children:"Loading project access\u2026"}),l?.policyState==="error"&&(0,P.jsx)(C,{className:"min-h-11 w-full sm:w-auto",type:"button",onClick:()=>t.loadProjectPolicies([l.id],!0),children:"Try again loading project access"}),(k==="organization"?["Packages","Project records","Organization"]:["Packages","Project records"]).map(g=>(0,P.jsxs)("fieldset",{children:[(0,P.jsx)("legend",{children:g}),E.filter(b=>g==="Organization"?b.scope==="organization":g==="Packages"?Z.includes(b.name)||b.name==="project:packages:write":b.scope==="project"&&!Z.includes(b.name)&&b.name!=="project:packages:write").map(b=>(0,P.jsxs)("label",{className:"flex min-h-11 items-center gap-2",children:[(0,P.jsx)("input",{type:"checkbox",checked:f.includes(b.name)&&v.includes(b.name),disabled:!v.includes(b.name),"aria-invalid":!!N&&o==="principal-permissions",onChange:T=>{S("Custom"),i(K=>T.target.checked?[...K,b.name]:K.filter(q=>q!==b.name))}}),Y[b.name]?.[0]??b.description," \u2014 ",Y[b.name]?.[1],!v.includes(b.name)&&" You cannot grant this permission here."]},b.name))]},g)),(0,P.jsx)("p",{children:"A token's access level and the project's access policy may limit these permissions further."})]}),(0,P.jsxs)("p",{className:"lg:col-span-2",children:[a," \xB7 ",k==="organization"?"Organization-wide":l?.name," \xB7"," ",f.length," ",f.length===1?"permission":"permissions"]}),(0,P.jsxs)("div",{className:"flex flex-wrap gap-2 lg:col-span-2",children:[(0,P.jsx)(C,{className:"min-h-11 w-full sm:w-auto",type:"submit",disabled:e.busy,children:e.busy?"Creating service principal\u2026":"Create service principal"}),(0,P.jsx)(C,{className:"min-h-11 w-full sm:w-auto",type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"})]})]})]}):null}var d=B(H(),1),Fe="Create token",W={read:"Install and download",write:"Include publish permission",full:"Include grants, sources and audit access"},Me={"project:read":"Read project details","project:packages:read":"Install and download packages","project:packages:write":"Include publish permission","project:grants:read":"Read project grants","project:sources:read":"Read project sources","project:audit:read":"Read project audit records"},Oe={read:"Read project details and download packages.",write:"Also include the package publishing permission. Publish npm packages to an enabled hosted source that claims the package name.",full:"Also allow reading project grants, sources and audit records, plus the publish permission."},Ne={read:"project:packages:read",write:"project:packages:write",full:null},Ue={read:["project:read","project:packages:read"],write:["project:read","project:packages:read","project:packages:write"],full:null};function xe(e,t,n){let u=Ue[t];return[...new Set(e.filter(a=>se.includes(a)&&(u===null||u.includes(a))&&(n||a.startsWith("project:"))))].sort()}function Ke(e,t,n){if(!t)return"Choose a service identity first.";if(!t.length)return"This service identity has no permissions.";let u=xe(t,e,!0),a=Ne[e];return a!==null&&!u.includes(a)?"The service identity needs the required package permission.":u.length?u.some(p=>!n.includes(p))?"You cannot confer this service identity\u2019s permissions at this access level.":null:"This service identity has no token-eligible permissions at this access level."}function Ie(e,t,n,u){if(!t.length)return"Choose a project first.";let a={read:0,write:1,full:2};for(let p of t){if(p.policyState==="idle"||p.policyState==="loading")return"Loading project access\u2026";if(p.cap===null||p.permissions===null)return"Project policy or permissions could not be loaded. Try again.";if(a[e]>a[p.cap])return"This access level is not available for every selected project. Choose Install and download or change the selected projects.";let k=e==="read"?"project:packages:read":"project:packages:write";if(n&&!p.permissions.includes(k))return e==="full"?"Creating this access level requires package publishing permission on every selected project, even when you only need audit access.":"Your access does not include the required package permission for every selected project.";if(!n){if(!p.permissions.includes("project:tokens:create"))return"You need permission to create tokens for this project.";if(!u)return"Choose a service identity first.";if(!u.length)return"This service identity has no permissions. Choose another identity or ask an organization administrator to grant it access.";let s=xe(u,e,!1);if(e!=="full"&&!s.includes(Ne[e]))return"The service identity needs the required package permission.";if(!s.length||s.some(f=>!p.permissions.includes(f)))return"You cannot confer this service identity\u2019s permissions at this access level."}}return null}var le=()=>({name:"",scope:"read",days:"",project:"",ids:[],mode:"selected",principal:""});function Se(e){return e.length<1||e.length>200?"Choose between 1 and 200 projects.":null}function Ve(e,t){return e.principals.filter(n=>n.status==="active"&&n.projectId===t)}function Te({state:e,controller:t,initialAudience:n="ci",defaultOpen:u=!1}){let a=e.issuanceDraft,[p,k]=(0,$.useState)(u||a!==null),[s,f]=(0,$.useState)(a?a.target==="personal":n==="personal"),i=()=>a?{name:a.draft.name,scope:a.draft.scope,days:String(a.draft.lifetimeDays),project:a.target==="organization"?"__organization":a.project??"",ids:a.draft.projectIds,mode:a.draft.projectMode,principal:a.draft.servicePrincipalId}:le(),[x,S]=(0,$.useState)(()=>a&&a.target!=="personal"?i():{...le(),project:e.issuanceProject??""});(0,$.useEffect)(()=>{e.issuanceProject!==null&&S(c=>({...c,project:e.issuanceProject,principal:e.issuancePrincipal??c.principal,scope:e.issuanceProject==="__organization"?"full":c.scope})),e.issuancePrincipal&&(k(!0),f(!1))},[e.issuanceProject,e.issuancePrincipal,e.issuanceNonce]);let[N,I]=(0,$.useState)(()=>a?.target==="personal"?i():le());(0,$.useEffect)(()=>{if(!a)return;let c={name:a.draft.name,scope:a.draft.scope,days:String(a.draft.lifetimeDays),project:a.target==="organization"?"__organization":a.project??"",ids:a.draft.projectIds,mode:a.draft.projectMode,principal:a.draft.servicePrincipalId};(a.target==="personal"?I:S)(c),f(a.target==="personal"),k(!0)},[a]);let[o,h]=(0,$.useState)(""),[m,w]=(0,$.useState)(null),[l,v]=(0,$.useState)(null),E=s?l:m,A=s?v:w,y=s?N:x,g=c=>(s?I:S)(z=>({...z,...c})),b=s?e.projects.filter(c=>y.mode==="all"?c.permissions===null||c.permissions.some(z=>z==="project:packages:read"||z==="project:packages:write"):y.ids.includes(c.id)):e.projects.filter(c=>c.slug===y.project),T=!s&&y.project==="__organization",K=Ve(e,T?null:b[0]?.id),q=K.find(c=>c.id===y.principal),O=e.lifetime?.[s?"personal":"service"],ee=y.days||String(O?.defaultDays??""),V=s&&y.mode==="all",de=c=>q?Ke(c,q.permissions,e.organizationPermissions):"Choose a service identity first.",ue=V?null:T?de(y.scope):Ie(y.scope,b,s,q?.permissions),oe=b.map(c=>c.id).join(",");(0,$.useEffect)(()=>{p&&!V&&t.loadProjectPolicies(oe?oe.split(","):[])},[t,p,V,oe,e.projects]);function Le(){return y.name.trim()?e.projectsError&&!V?{message:"Projects could not be loaded. Try again.",target:s?"project-search":"issue-project"}:s&&y.mode==="selected"&&Se(y.ids)?{message:Se(y.ids),target:"project-search"}:!s&&!y.project?{message:"Choose a project first.",target:"issue-project"}:!s&&!q?{message:"Choose a service identity first.",target:"issue-principal"}:ue?{message:ue,target:"issue-access"}:!O||!ie(O).includes(Number(ee))?{message:"Choose an available lifetime.",target:"issue-lifetime"}:null:{message:"Enter a token name.",target:"issue-name"}}function Re(){k(!1),document.getElementById("new-token")?.focus()}return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(C,{className:"min-h-11",id:"new-token",type:"button",onClick:()=>k(!0),children:"New token"}),p?(0,d.jsxs)("form",{noValidate:!0,className:"grid max-w-5xl items-start gap-x-6 gap-y-4 lg:grid-cols-2",onSubmit:c=>{c.preventDefault();let z=Le();if(z){A(z),requestAnimationFrame(()=>document.getElementById("token-errors")?.focus());return}A(null),t.issueFor(s?"personal":T?"organization":"project",s||T?null:y.project,{name:y.name,scope:y.scope,lifetimeDays:Number(ee),servicePrincipalId:s?"":y.principal,projectMode:s?y.mode:"selected",projectIds:s&&y.mode==="selected"?y.ids:[]})},children:[(0,d.jsx)("h2",{className:"lg:col-span-2",children:"New token"}),(0,d.jsxs)("fieldset",{className:"lg:col-span-2",children:[(0,d.jsx)("legend",{children:"Who is this token for?"}),(0,d.jsxs)("label",{className:"flex min-h-11 items-center gap-2",children:[(0,d.jsx)("input",{type:"radio",name:"audience",checked:!s,onChange:()=>{f(!1)}}),"A CI pipeline or service"]}),(0,d.jsx)("p",{children:"Keeps working when the person who created it leaves."}),(0,d.jsxs)("label",{className:"flex min-h-11 items-center gap-2",children:[(0,d.jsx)("input",{type:"radio",name:"audience",checked:s,onChange:()=>{f(!0)}}),"Me"]}),(0,d.jsx)("p",{children:"Uses your access. Stops working if you leave or your account is suspended."})]}),E&&(0,d.jsx)("div",{id:"token-errors",role:"alert",tabIndex:-1,className:"lg:col-span-2",children:(0,d.jsx)("button",{type:"button",className:"min-h-11 underline",onClick:()=>document.getElementById(E.target)?.focus(),children:E.message})}),(0,d.jsxs)("div",{children:[(0,d.jsx)(D,{htmlFor:"issue-name",children:"Token name"}),(0,d.jsx)(U,{className:"min-h-11",id:"issue-name",value:y.name,"aria-invalid":!!E&&!y.name.trim(),"aria-describedby":E?"token-errors":void 0,placeholder:s?"e.g. My laptop":"e.g. Storefront CI",onChange:c=>g({name:c.target.value})})]}),s?(0,d.jsxs)("fieldset",{children:[(0,d.jsx)("legend",{children:"Which projects?"}),["selected","all"].map(c=>(0,d.jsxs)("label",{className:"flex min-h-11 items-center gap-2",children:[(0,d.jsx)("input",{type:"radio",name:"projects-mode",checked:y.mode===c,onChange:()=>g({mode:c})}),c==="selected"?"Choose projects":"All projects I can access"]},c)),y.mode==="all"?(0,d.jsx)("p",{children:"Includes projects you can access now and projects you gain access to later."}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(D,{htmlFor:"project-search",children:"Search projects"}),(0,d.jsx)(U,{className:"min-h-11",id:"project-search",value:o,onChange:c=>h(c.target.value)}),(0,d.jsx)("p",{id:"project-help",children:"Choose up to 200 projects. This does not give you access you do not already have."}),(0,d.jsxs)("p",{children:[y.ids.length," ",y.ids.length===1?"project selected":"projects selected"]}),(0,d.jsx)("div",{className:"max-h-60 overflow-y-auto",children:e.projects.filter(c=>c.name.toLowerCase().includes(o.toLowerCase())).map(c=>(0,d.jsxs)("label",{className:"flex min-h-11 items-center gap-2",children:[(0,d.jsx)("input",{type:"checkbox",checked:y.ids.includes(c.id),disabled:!y.ids.includes(c.id)&&y.ids.length>=200,"aria-describedby":"project-help",onChange:z=>g({ids:z.target.checked?[...y.ids,c.id]:y.ids.filter(ze=>ze!==c.id)})}),c.name]},c.id))})]})]}):(0,d.jsxs)("div",{children:[(0,d.jsx)(D,{htmlFor:"issue-project",children:"Project"}),(0,d.jsxs)(L,{className:"min-h-11","aria-invalid":!!E&&!y.project,"aria-describedby":E?"token-errors":void 0,id:"issue-project",value:y.project,onChange:c=>g({project:c.target.value,principal:"",scope:c.target.value==="__organization"?"full":"read"}),children:[(0,d.jsx)("option",{value:"",children:"Choose a project"}),e.projects.map(c=>(0,d.jsx)("option",{value:c.slug,children:c.name},c.id)),e.organizationPermissions.includes("org:settings:write")&&e.organizationPermissions.includes("org:service-principals:write")&&(0,d.jsx)("option",{value:"__organization",children:"Organization-wide (advanced)"})]}),y.project===""&&y.principal!==""&&e.principals.some(c=>c.id===y.principal&&c.projectId!==null)&&(0,d.jsx)("p",{children:"Project name unavailable. You may not have access to this service identity\u2019s project."})]}),e.projectsError&&(0,d.jsxs)("p",{className:"lg:col-span-2",children:["Projects could not be loaded."," ",(0,d.jsx)(C,{type:"button",onClick:()=>{t.identity()},children:"Try again"})]}),(0,d.jsxs)("fieldset",{id:"issue-access",tabIndex:-1,className:"lg:col-span-2","aria-describedby":"access-help",children:[(0,d.jsx)("legend",{children:"What can this token do?"}),["read","write","full"].map(c=>{let z=V?null:T?de(c):Ie(c,b,s,q?.permissions);return(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"flex min-h-11 items-center gap-2",children:[(0,d.jsx)("input",{type:"radio",name:"access",checked:y.scope===c,disabled:z!==null,"aria-invalid":E?.target==="issue-access",onChange:()=>g({scope:c}),"aria-describedby":`help-${c}`}),W[c]]}),(0,d.jsxs)("p",{id:`help-${c}`,children:[Oe[c]," ",z]})]},c)}),b.filter(c=>!V||c.policyState==="error").map(c=>(0,d.jsx)("p",{children:c.cap&&!V?`${c.name} allows ${{read:"install and download only",write:"install, download and publish permission",full:"all token-eligible project permissions"}[c.cap]}.`:`${c.name}: ${c.policyState==="loading"?"Loading project access\u2026":c.policyState==="error"?"Project access could not be loaded.":"Project access has not been loaded."}`},c.id)),b.some(c=>c.policyState==="error")&&(0,d.jsx)(C,{type:"button",onClick:()=>t.loadProjectPolicies(b.filter(c=>c.policyState==="error").map(c=>c.id),!0),children:"Try again loading project access"}),T&&(0,d.jsx)("p",{children:"This token may also use the service identity\u2019s organization permissions. Project policies only limit access within projects."}),(0,d.jsx)("p",{id:"access-help",children:"Your token can only use permissions its holder has and the project allows. Tokens cannot change project settings or delete packages. Publishing is not available in this version."})]}),!s&&(0,d.jsxs)("div",{children:[(0,d.jsx)(D,{htmlFor:"issue-principal",children:"Service identity"}),(0,d.jsxs)(L,{className:"min-h-11","aria-invalid":!!E&&!q,"aria-describedby":E?"token-errors":void 0,id:"issue-principal",value:y.principal,onChange:c=>g({principal:c.target.value}),children:[(0,d.jsx)("option",{value:"",children:"Choose a service identity"}),K.map(c=>(0,d.jsx)("option",{value:c.id,children:c.name},c.id))]}),(0,d.jsx)("p",{children:"A service principal is an identity for automation. Its tokens keep working when the person who created them leaves."}),q&&(0,d.jsxs)("p",{children:["Permissions:"," ",(q.permissions??[]).map(c=>Me[c]??Y[c]?.[0]).filter(Boolean).join("; ")]}),e.principalsLoading?(0,d.jsx)("p",{children:"Loading service principals\u2026"}):e.principalsError?(0,d.jsxs)("p",{children:["Service principals could not be loaded."," ",(0,d.jsx)(C,{type:"button",onClick:()=>{t.loadPrincipals()},children:"Try again"})]}):(e.principalsRestricted||!K.length)&&(0,d.jsxs)("p",{children:[e.principalsRestricted&&"You cannot browse service principals here. ","Ask an organization administrator to create a service identity for this project."]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)(D,{htmlFor:"issue-lifetime",children:"Expires after"}),(0,d.jsx)(L,{className:"min-h-11",id:"issue-lifetime","aria-invalid":E?.target==="issue-lifetime","aria-describedby":E?.target==="issue-lifetime"?"token-errors":void 0,value:ee,disabled:!O,onChange:c=>g({days:c.target.value}),children:O&&ie(O).map(c=>(0,d.jsxs)("option",{value:c,children:[J(c),c===O.defaultDays?" (organization default)":""]},c))}),!O&&!e.loading&&(0,d.jsx)(C,{type:"button",onClick:()=>{t.load()},children:"Try again"}),(0,d.jsx)("p",{children:O?`Maximum: ${J(O.maxDays)}. Create a replacement before this token expires.`:"Lifetime policy could not be loaded."})]}),(0,d.jsx)("p",{className:"lg:col-span-2 break-words",children:[y.name,V?"All projects I can access":b.map(c=>c.name).join(", "),W[y.scope],J(Number(ee)),s?"":q?.name].filter(Boolean).join(" \xB7 ")}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2 lg:col-span-2",children:[(0,d.jsx)(C,{className:"min-h-11 w-full sm:w-auto",type:"submit",disabled:e.busy,children:e.busy?"Creating token\u2026":Fe}),(0,d.jsx)(C,{className:"min-h-11 w-full sm:w-auto",type:"button",variant:"outline",disabled:e.busy,onClick:Re,children:"Cancel"})]})]}):null]})}function ce(e){return`'${e.replaceAll("'","'\\''")}'`}function Ee(e,t,n){let u=new URL(e),a=`${u.origin}/${encodeURIComponent(t)}`,p=`registry=${a}/npm/`,k=`//${u.host}/${encodeURIComponent(t)}/npm/:_authToken=`;return{composer:`composer config ${ce(`repositories.${t}`)} composer ${ce(a)}`,composerAuth:JSON.stringify({bearer:{[u.host]:n}},null,2),npm:`${p}
2
+ ${k}${n}`,ciComposer:`export COMPOSER_AUTH="$(printf ${ce(JSON.stringify({bearer:{[u.host]:"%s"}}).replaceAll("%","%%").replace("%%s","%s"))} "$PACKAGE_BROKER_TOKEN")"
3
+ composer install --no-interaction`,ciNpm:`${p}
4
+ ${k}\${PACKAGE_BROKER_TOKEN}`}}var r=B(H(),1),J=e=>`${e} ${e===1?"day":"days"}`;function ie(e){return[...new Set([30,90,180,365,e.maxDays,e.defaultDays])].filter(t=>t>0&&t<=e.maxDays).sort((t,n)=>t-n)}function He(e,t){return t.type==="navigate"?{...e,secret:null,secretProject:null,result:null,issuedId:null,oldPersonalId:null,pending:null,renewal:null,busy:!1,notice:null}:e}function De(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function We(e){if(!De(e)||!De(e.draft))return null;let t=e.draft;return!["personal","project","organization"].includes(String(e.target))||!(e.project===null||typeof e.project=="string")||typeof e.key!="string"||typeof t.name!="string"||!["read","write","full"].includes(String(t.scope))||!Number.isInteger(t.lifetimeDays)||Number(t.lifetimeDays)<1||typeof t.servicePrincipalId!="string"||!["all","selected"].includes(String(t.projectMode))||!Array.isArray(t.projectIds)||!t.projectIds.every(n=>typeof n=="string")||e.rotate!==void 0&&typeof e.rotate!="string"||e.replace!==void 0&&typeof e.replace!="string"||t.overlapDays!==void 0&&![0,1,7].includes(Number(t.overlapDays))?null:{target:e.target,project:e.project,key:e.key,...e.refresh===!0?{refresh:!0}:{},...["personal","project","organization"].includes(String(e.listTarget))?{listTarget:e.listTarget,listProject:typeof e.listProject=="string"?e.listProject:null}:{},...typeof e.rotate=="string"?{rotate:e.rotate}:{},...typeof e.replace=="string"?{replace:e.replace}:{},draft:{name:t.name,scope:t.scope,lifetimeDays:Number(t.lifetimeDays),servicePrincipalId:t.servicePrincipalId,projectMode:t.projectMode,projectIds:[...t.projectIds],...t.overlapDays===void 0?{}:{overlapDays:Number(t.overlapDays)}}}}function Ge(e){return{id:e.id,kind:e.kind,name:e.name,scope:e.scope,readOnly:e.readOnly,status:e.status,projectMode:e.projectMode,projectCount:e.projectCount,projectId:e.projectId,userId:e.userId,createdByUserId:e.createdByUserId,servicePrincipalId:e.servicePrincipalId,createdAt:e.createdAt,expiresAt:e.expiresAt,lastUsedAt:e.lastUsedAt,revokedAt:e.revokedAt}}function Ae(e,t){return e?e.target==="project"?t.slug===e.project:e.target==="personal"?e.draft.projectMode!=="selected"||e.draft.projectIds.includes(t.id):!0:!0}function pe(e,t){let n=e.result;if(!n)return!1;let u=n.target==="personal"?t.permissions:e.principals.find(a=>a.id===n.draft.servicePrincipalId)?.permissions;return u?.includes("project:packages:read")===!0||n.draft.scope!=="read"&&t.cap!=="read"&&u?.includes("project:packages:write")===!0}function Ye(e,t){let n={target:"personal",project:null,issuanceProject:null,items:[],next:null,principals:[],principalsNext:null,principalsRestricted:!1,principalsLoading:!0,principalsError:!1,organizationPermissions:[],issuanceDraft:null,issuancePrincipal:null,issuanceNonce:0,names:{},projectSlugs:{},projects:[],projectsError:!1,result:null,lifetime:null,userId:null,secret:null,secretProject:null,issuedId:null,oldPersonalId:null,pending:null,renewal:null,busy:!1,loading:!1,listError:!1,notice:null},u=0,a=0,p=0,k=[],s=0,f=new Set,i=o=>{n={...n,...o};for(let h of f)h()},x=be(t.storage);function S(o){o.code==="reauth_required"?e.requireReauth(o.request,{credential:!1,secretFields:[]}):i({notice:o.status===412||o.status===428?"The record changed. Reload before trying again.":"Unable to update tokens. Try again."})}async function N(o){if(n.busy)return;let h=++u;i({busy:!0,secret:null,secretProject:null,result:null,issuedId:null,oldPersonalId:null,pending:null,notice:null});let{draft:m,target:w,project:l,key:v}=o,E={name:m.name,scope:m.scope,lifetimeDays:m.lifetimeDays},A={...E,servicePrincipalId:m.servicePrincipalId},y={name:m.name,lifetimeDays:m.lifetimeDays,overlapDays:m.overlapDays??0},g=o.rotate!==void 0?w==="project"?await e.client.request("post","/_pb/projects/{project}/tokens/{token}/rotate",{params:{project:l,token:o.rotate},body:y,idempotencyKey:v}):await e.client.request("post","/_pb/tokens/{token}/rotate",{params:{token:o.rotate},body:y,idempotencyKey:v}):w==="personal"?await e.client.request("post","/_pb/me/tokens",{body:{...E,projectMode:m.projectMode,projectIds:m.projectIds},idempotencyKey:v}):w==="project"?await e.client.request("post","/_pb/projects/{project}/tokens",{params:{project:l},body:A,idempotencyKey:v}):await e.client.request("post","/_pb/tokens",{body:A,idempotencyKey:v});if(h===u)if(i({busy:!1}),g.ok)i({secret:g.data.token,secretProject:w==="project"?l:m.projectMode==="selected"&&m.projectIds.length===1?n.projectSlugs[m.projectIds[0]]??null:null,result:o,oldPersonalId:o.replace??null,issuedId:g.data.id,notice:"Token created."});else if(g.code==="reauth_required"){let b=me(x,{method:"POST",path:"/_pb/me/tokens",body:o,idempotencyKey:v,credential:!1,secretFields:[]});i({secret:null,notice:b.ok?"Confirm your identity, then confirm token issue.":"Unable to save the pending action."}),b.ok&&t.navigate(`#/reauth?return=${encodeURIComponent(`/tokens${l===null?"":`?project=${encodeURIComponent(l)}`}`)}`)}else g.code==="already_issued"?i({notice:"already issued, create a new token"}):S(g)}let I={trustedPublishers:ke(e),snapshot:()=>n,announce(o){i({notice:o})},subscribe(o){return f.add(o),()=>{f.delete(o)}},navigate(){I.trustedPublishers.clear(),u++,p++,a++,k.length=0,i({...He(n,{type:"navigate"}),principalsLoading:!1,projects:n.projects.map(o=>o.policyState==="loading"?{...o,policyState:"idle"}:o)})},dispose(){I.navigate(),f.clear()},closeSecret(){n.busy||(u++,i({secret:null,secretProject:null,result:null,issuedId:null,oldPersonalId:null,notice:null,renewal:null,issuanceDraft:n.pending===null?null:n.issuanceDraft}))},restore(){let o=ge(x,t.now()),h=o.ok?We(o.action?.body):null;h!==null&&i({pending:h,issuanceDraft:h.refresh?h:null,secret:null})},async start(o,h){i({issuanceProject:h}),I.restore();let m=n.pending;await I.load(m?.listTarget??m?.target??o,m?m.listTarget?m.listProject??null:m.project:h)},async selectTarget(o,h){n.busy||(i({pending:null,renewal:null}),await I.load(o,h))},decline(){i({pending:null})},async confirm(){let o=n.pending;o===null||n.busy||n.loading||n.lifetime===null&&(await I.load(),n.pending!==o||n.lifetime===null||n.loading)||(await N(o),o.refresh&&n.secret!==null&&await I.load())},async issueFor(o,h,m){let w={target:o,project:h,draft:m,key:t.newKey(),refresh:!0,listTarget:n.target,listProject:n.project};i({issuanceDraft:w}),await N(w),n.secret!==null&&await I.load()},configureProject(o){let h=n.result,m=n.projects.find(w=>w.slug===o);!m||!h||h.target==="project"&&h.project!==o||h.target==="personal"&&h.draft.projectMode==="selected"&&!h.draft.projectIds.includes(m.id)||i({secretProject:o})},async issue(o){await N({target:n.renewal?.kind==="pat"?"personal":n.renewal?.projectId?"project":n.target,project:n.renewal?.kind==="svc"&&n.renewal.projectId!==null?n.projectSlugs[n.renewal.projectId]??n.project:n.project,draft:o,key:t.newKey(),...n.renewal?.kind==="svc"?{rotate:n.renewal.id}:{},...n.renewal?.kind==="pat"?{replace:n.renewal.id}:{}})},renew(o){if(!(n.busy||o.kind==="pat"&&o.userId!==n.userId)){if(o.kind==="svc"&&o.projectId!==null&&n.projectSlugs[o.projectId]===void 0&&n.target!=="project"){i({notice:"Choose this token\u2019s project scope before renewing."});return}i({renewal:o,secret:null,issuedId:null,oldPersonalId:null,notice:null})}},invalidProjects(){i({notice:"Choose between 1 and 200 projects."})},registryOrigin:()=>new URL(t.origin).origin,clientConfig(){return n.secret===null||n.secretProject===null?null:Ee(t.origin,n.secretProject,n.secret)},async copy(o){if(n.secret===null)return;let h=o===void 0?n.secret:I.clientConfig()?.[o];if(h===void 0)return;let m=o===void 0?"Token":"Configuration",w=u;try{await t.clipboard(h),w===u&&i({...t.clearAfterCopy?{secret:null}:{},notice:`${m} copied.`})}catch{w===u&&i({notice:o===void 0?"Could not copy. Select and copy the token manually.":"Could not copy. Select and copy the configuration manually."})}},async load(o=n.target,h=n.project,m){let w=++a;i({target:o,project:h,loading:!0,listError:!1,notice:n.secret===null?null:n.notice,items:[],next:null,lifetime:null});let l=o==="personal"?await e.client.request("get","/_pb/me/tokens",{query:{after:m}}):o==="project"&&h!==null?await e.client.request("get","/_pb/projects/{project}/tokens",{params:{project:h},query:{after:m}}):await e.client.request("get","/_pb/tokens",{query:{after:m}});w===a&&i(l.ok?{items:l.data.items.map(Ge),next:l.data.next,lifetime:l.data.lifetime,loading:!1}:{loading:!1,listError:!0,lifetime:null,notice:"Unable to load tokens."})},async loadPrincipals(o){let h=p;i({principalsLoading:!0,principalsError:!1});let m=[],w=o;do{let l=await e.client.request("get","/_pb/service-principals",{query:{after:w}});if(h!==p)return;if(!l.ok){i({principalsLoading:!1,principalsError:l.status!==403,principalsRestricted:l.status===403,principals:[],principalsNext:null});return}m.push(...l.data.items.map(v=>({id:v.id,name:v.name,projectId:v.projectId,status:v.status,revision:v.revision,createdByUserId:v.createdByUserId,permissions:v.permissions}))),w=l.data.next??void 0}while(w!==void 0);i({principals:m,principalsNext:null,principalsRestricted:!1,principalsLoading:!1})},loadProjectPolicies(o,h=!1){let m=new Set;for(let l of o){let v=n.projects.find(E=>E.id===l);!v||v.policyState==="loading"||v.policyState==="loaded"||!h&&v.policyState==="error"||(m.add(l),k.push(l))}m.size&&i({projects:n.projects.map(l=>m.has(l.id)?{...l,policyState:"loading"}:l)});async function w(){s++;try{for(;k.length;){let l=k.shift(),v=n.projects.find(g=>g.id===l);if(!v)continue;let E=p,A=await e.client.request("get","/_pb/projects/{project}",{params:{project:v.slug}}),y=await e.client.request("get","/_pb/projects/{project}/permissions",{params:{project:v.slug}});E===p&&i({projects:n.projects.map(g=>g.id===l?{...g,cap:A.ok?A.data.tokenMaxScope:null,permissions:y.ok?y.data.project:null,policyState:A.ok&&y.ok?"loaded":"error"}:g)})}}finally{s--}}for(;k.length&&s<4;)w()},choosePrincipal(o,h,m=h===null){i({issuancePrincipal:o,issuanceProject:m?"__organization":h??"",issuanceNonce:n.issuanceNonce+1})},async identity(){let o=p,h=e.client.request("get","/_pb/session"),m={},w=[],l=!1,v;do{let b=await e.client.request("get","/_pb/projects",{query:{after:v}});if(o!==p)return;if(!b.ok){l=!0;break}for(let T of b.data.items)m[T.id]=T.slug,T.status!=="archived"&&w.push({id:T.id,slug:T.slug,name:T.name??T.slug,cap:null,permissions:null,policyState:"idle"});v=b.data.next??void 0,i({projectSlugs:{...m},projects:[...w],projectsError:l})}while(v!==void 0);i({projectSlugs:m,projects:w,projectsError:l});let E=await h;if(o!==p)return;E.ok&&i({userId:E.data.user.id});let A=await e.client.request("get","/_pb/me/permissions");if(o!==p)return;if(i({organizationPermissions:A.ok?A.data.organization:[]}),!A.ok||!A.data.organization.includes("org:users:read")){i({names:{}});return}let y,g={};do{let b=await e.client.request("get","/_pb/users",{query:{after:y}});if(o!==p)return;if(!b.ok)break;for(let T of b.data.items)T.displayName!==null&&(g[T.id]=T.displayName);y=b.data.next??void 0}while(y!==void 0);o===p&&i({names:g})},async revoke(o,h=!1){if(n.busy)return;let m=u;i({busy:!0,secret:null,issuedId:null});let w=n.target==="personal"||h?await e.client.request("delete","/_pb/me/tokens/{token}",{params:{token:o}}):n.target==="project"?await e.client.request("delete","/_pb/projects/{project}/tokens/{token}",{params:{project:n.project,token:o}}):await e.client.request("delete","/_pb/tokens/{token}",{params:{token:o}});m===u&&(i({busy:!1}),w.ok?(await I.load(),i({notice:"Token revoked.",renewal:null})):S(w))},async createPrincipal(o,h,m){if(n.busy)return;let w=u;i({busy:!0,secret:null,issuedId:null});let l={name:o,permissions:m,...h===""?{}:{project:h}},v=await e.client.request("post","/_pb/service-principals",{body:l,idempotencyKey:t.newKey()});if(w===u)if(i({busy:!1}),!v.ok)S(v);else return await I.loadPrincipals(),i({notice:"Service principal created. Create a token to use it."}),v.data},async suspendPrincipal(o){if(n.busy)return;let h=u;i({busy:!0,secret:null,issuedId:null});let m=o.projectId===null?void 0:n.projectSlugs[o.projectId],w=m!==void 0?await e.client.request("post","/_pb/projects/{project}/service-principals/{principal}/suspend",{params:{project:m,principal:o.id}}):await e.client.request("post","/_pb/service-principals/{principal}/suspend",{params:{principal:o.id}});h===u&&(i({busy:!1}),w.ok?(await I.loadPrincipals(),i({notice:"Service principal suspended; its tokens no longer work."})):S(w))}};return I}function Je(e,t){return e.filter(n=>n.name.toLowerCase().includes(t.q.toLowerCase())&&(!t.scope||n.scope===t.scope||W[n.scope]===t.scope)&&(!t.status||n.status===t.status))}function Qe({state:e,controller:t}){let[n,u]=(0,M.useState)({q:"",scope:"",status:""}),a=!!(n.q||n.scope||n.status),p=Je(e.items,n),k=e.target==="personal"?"My personal tokens":e.target==="project"?`Project: ${e.project}`:"Organization";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(je,{values:n,fields:[{key:"q",label:"Name (this page)"},{key:"scope",label:"Scope",options:Object.values(W)},{key:"status",label:"Status",options:["active","expired","revoked"]}],onChange:u}),(0,r.jsxs)("div",{className:"my-3 flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsxs)("p",{className:"text-sm text-neutral-600",children:[p.length," tokens on this page \xB7"," ",p.filter(s=>s.status==="active").length," active"]}),(0,r.jsx)(C,{type:"button",variant:"outline",disabled:e.loading||e.busy,onClick:()=>{t.load()},children:"Reload tokens"})]}),e.loading?(0,r.jsx)(F,{kind:"loading",title:"Loading tokens\u2026"}):e.listError?(0,r.jsx)(F,{kind:"error",title:"Unable to load tokens."}):p.length===0?(0,r.jsx)(F,{kind:a?"filtered-empty":"empty",title:a?"No tokens match these filters on this page.":"No tokens on this page."}):(0,r.jsx)(Q,{label:"Tokens",items:p,columns:[{key:"name",label:"Token",value:s=>s.name,render:s=>(0,r.jsxs)("div",{className:"grid gap-1",children:[(0,r.jsx)("strong",{children:s.name}),(0,r.jsx)(ne,{value:s.id,label:"token ID"})]})},{key:"status",label:"Status",value:s=>s.status,render:s=>(0,r.jsx)(ae,{status:s.status})},{key:"scope",label:"Scope",value:s=>s.scope,render:s=>(0,r.jsx)(ve,{variant:"outline",children:W[s.scope]})},{key:"project",label:"Project",value:s=>s.projectId===null?s.kind==="pat"?s.projectMode==="all"?"All accessible projects":`${s.projectCount} selected projects`:"Organization":e.projectSlugs[s.projectId]??s.projectId,priority:2,render:s=>s.projectId!==null&&!e.projectSlugs[s.projectId]?(0,r.jsx)(ne,{value:s.projectId,label:"project ID"}):s.projectId!==null?e.projectSlugs[s.projectId]:s.kind==="pat"?s.projectMode==="all"?"All accessible projects":`${s.projectCount} selected projects`:"Organization"},{key:"lastUsedAt",label:"Last used",value:s=>s.lastUsedAt??"",priority:2,render:s=>(0,r.jsx)(X,{value:s.lastUsedAt,fallback:"Never"})},{key:"expiresAt",label:"Expires",value:s=>s.expiresAt??"",priority:3,render:s=>(0,r.jsx)(X,{value:s.expiresAt,fallback:"None"})},{key:"issuer",label:"Issued by",value:s=>s.kind==="svc"&&s.createdByUserId!==null?e.names[s.createdByUserId]??"a member":"a member",priority:3},{key:"actions",label:"Actions",value:()=>"",sortable:!1,render:s=>(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(C,{type:"button",size:"sm",variant:"outline",disabled:e.busy||s.status!=="active"||s.kind==="pat"&&s.userId!==e.userId,onClick:()=>t.renew(s),children:"Renew"}),(0,r.jsx)(G,{action:"Revoke",target:`${s.name} (${s.id})`,scope:k,description:"Revoking this token stops clients using it from authenticating. This cannot be undone. Create a new token to restore client access.",disabled:e.busy||s.status==="revoked",onConfirm:()=>{t.revoke(s.id)}},`${s.id}:${s.status}`)]})}]}),e.next===null?null:(0,r.jsx)(C,{type:"button",disabled:e.busy||e.loading,onClick:()=>{t.load(e.target,e.project,e.next)},children:"Next tokens"}),(0,r.jsx)("p",{className:"mt-3 text-xs text-neutral-600",children:"Secrets are never listed. Only tokens in your accessible scope appear here."})]})}function Xe(e){e?.focus()}function Ze({state:e,controller:t}){let[n,u]=(0,M.useState)(""),a=e.projects.find(p=>p.id===n);return(0,M.useEffect)(()=>{e.secret&&a?.policyState==="loaded"&&pe(e,a)&&t.configureProject(a.slug)},[t,e.secret,a]),(0,r.jsxs)(r.Fragment,{children:[" ",e.projects.some(p=>p.permissions===null)&&(0,r.jsxs)("details",{children:[(0,r.jsx)("summary",{className:"min-h-11 cursor-pointer",children:"Check another project's package access"}),(0,r.jsx)(D,{htmlFor:"setup-candidate",children:"Project to configure"}),(0,r.jsxs)(L,{id:"setup-candidate",className:"min-h-11",value:n,onChange:p=>{u(p.target.value),t.loadProjectPolicies([p.target.value])},children:[(0,r.jsx)("option",{value:"",children:"Choose a project"}),e.projects.filter(p=>Ae(e.result,p)).map(p=>(0,r.jsx)("option",{value:p.id,children:p.name},p.id))]}),a?.policyState==="loading"&&(0,r.jsx)("p",{children:"Loading project access\u2026"}),a?.policyState==="error"&&(0,r.jsx)(C,{type:"button",onClick:()=>t.loadProjectPolicies([a.id],!0),children:"Try again loading project access"}),a?.policyState==="loaded"&&!pe(e,a)&&(0,r.jsx)("p",{children:"This token does not have package access to this project."})]})]})}function et({state:e,controller:t}){let n=e.renewal!==null?e.renewal.kind==="pat":e.target==="personal",u=e.lifetime?.[n?"personal":"service"],a=e.renewal,p=t.clientConfig(),k=a?.kind==="svc"?a.projectId:e.target==="project"?Object.keys(e.projectSlugs).find(i=>e.projectSlugs[i]===e.project):null,s=e.principals.filter(i=>i.status==="active");function f(i){if(i.preventDefault(),e.busy)return;let x=i.currentTarget,S=new FormData(x),N=S.getAll("projectIds").map(String);if(n&&S.get("projectMode")==="selected"&&(N.length<1||N.length>200)){t.invalidProjects();return}let I=a?.kind==="svc"?a.scope:String(S.get("scope"));t.issue({name:String(S.get("name")),scope:I,lifetimeDays:Number(S.get("lifetimeDays")),servicePrincipalId:String(S.get("principal")??""),projectMode:S.get("projectMode")==="selected"?"selected":"all",projectIds:S.getAll("projectIds").map(String),overlapDays:Number(S.get("overlap")??0)})}return(0,r.jsxs)("section",{"aria-labelledby":"page-heading",className:"space-y-4",children:[(0,r.jsx)("h1",{tabIndex:-1,id:"page-heading",className:"text-xl font-semibold",children:"Tokens"}),(0,r.jsx)("p",{className:"text-neutral-600",children:"Connect your tools and CI pipelines to your packages."}),e.notice===null||e.listError?null:(0,r.jsx)(fe,{role:"status","aria-live":"polite",children:(0,r.jsx)(he,{children:e.notice})}),e.pending===null?null:(0,r.jsxs)("section",{"aria-label":"Confirm token issue",className:"space-y-2",children:[(0,r.jsx)("h2",{children:"Confirm token issue"}),(0,r.jsx)("p",{children:"Your identity was checked. Issue this token now?"}),(0,r.jsx)(C,{type:"button",disabled:e.busy||e.loading||e.lifetime===null,onClick:()=>{t.confirm()},children:"Confirm token issue"}),(0,r.jsx)(C,{type:"button",variant:"outline",onClick:()=>t.decline(),children:"Cancel"})]}),e.secret===null?null:(0,r.jsxs)("section",{"aria-label":"Token secret",className:"detail-group space-y-3 border-emerald-200",children:[(0,r.jsx)("h2",{tabIndex:-1,ref:Xe,children:"Token created"}),e.result&&(0,r.jsxs)("p",{className:"break-words",children:[e.result.draft.name," \xB7"," ",e.result.target==="project"?e.projects.find(i=>i.slug===e.result?.project)?.name??"Project name unavailable":e.result.target==="organization"?"Organization-wide":e.result.draft.projectMode==="all"?"All accessible projects":e.result.draft.projectIds.length===1?e.projects.find(i=>i.id===e.result?.draft.projectIds[0])?.name??"1 selected project":`${e.result.draft.projectIds.length} selected projects`," ","\xB7 ",W[e.result.draft.scope]," \xB7 Expires after"," ",J(e.result.draft.lifetimeDays)]}),(0,r.jsx)("p",{children:"Copy this token now. You cannot view it again. Closing this panel keeps it active."}),(0,r.jsx)("pre",{className:"rounded-md border bg-neutral-50 p-3 overflow-x-auto whitespace-pre-wrap break-all",children:(0,r.jsx)("code",{role:"region","aria-label":"Created token",children:e.secret})}),(0,r.jsx)(C,{className:"min-h-11",type:"button",onClick:()=>{t.copy()},children:"Copy token"}),(0,r.jsx)(C,{type:"button",variant:"outline",className:"min-h-11",onClick:()=>{t.closeSecret(),requestAnimationFrame(()=>document.getElementById("new-token")?.focus())},children:"Done"}),(0,r.jsx)(Ze,{state:e,controller:t}),(0,r.jsx)(D,{htmlFor:"configure-project",children:"Configure for project"}),(0,r.jsxs)(L,{className:"min-h-11",id:"configure-project",value:e.secretProject??"",onChange:i=>t.configureProject(i.target.value),children:[(0,r.jsx)("option",{value:"",children:"Choose a project"}),e.projects.filter(i=>pe(e,i)).filter(i=>Ae(e.result,i)).map(i=>(0,r.jsx)("option",{value:i.slug,children:i.name},i.id))]}),p===null?(0,r.jsx)("p",{children:"Choose a project this token can access to configure Composer or npm."}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{children:"Composer sends this credential to this registry host. The token still limits which projects it can access."}),[["Composer",["composer","composerAuth"]],["npm",["npm"]],["CI environment",["ciComposer","ciNpm"]]].map(([i,x],S)=>(0,r.jsxs)("details",{open:S===0,className:"min-w-0",children:[(0,r.jsx)("summary",{className:"min-h-11 cursor-pointer",children:i}),x.map(N=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{children:{composer:"Composer repository command",composerAuth:"Merge this into your local auth.json. Do not commit credentials.",npm:"Use this on your computer. For CI, use the environment-variable version below.",ciComposer:"Save PACKAGE_BROKER_TOKEN as a secret in your CI settings. These examples install packages; they do not publish them.",ciNpm:"Save this as .npmrc, then run npm ci."}[N]}),(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-all rounded-md border bg-neutral-50 p-3",children:(0,r.jsx)("code",{children:p[N]})}),(0,r.jsx)(C,{type:"button",variant:"outline",className:"min-h-11",onClick:()=>{t.copy(N)},children:{composer:"Copy Composer configuration",composerAuth:"Copy auth.json",npm:"Copy npm configuration",ciComposer:"Copy CI Composer",ciNpm:"Copy CI npm"}[N]})]},N))]},i))]}),e.oldPersonalId!==null?(0,r.jsx)(G,{action:"Revoke old personal token",target:e.oldPersonalId,scope:"My personal tokens",description:"Clients using the old token will lose access immediately. This cannot be undone. Update clients to the new token before revoking.",disabled:e.busy,onConfirm:()=>{t.revoke(e.oldPersonalId,!0)}}):null]}),(0,r.jsx)("div",{hidden:e.pending!==null||e.secret!==null||a!==null,children:(0,r.jsx)(Te,{state:e,controller:t})}),e.pending!==null||e.secret!==null||a===null?null:(0,r.jsxs)("details",{open:a!==null,className:"detail-group",children:[(0,r.jsx)("summary",{className:"min-h-11 cursor-pointer font-semibold",children:a===null?"Issue token":"Renew token"}),(0,r.jsxs)("form",{onSubmit:f,className:"grid gap-2",children:[(0,r.jsx)(D,{htmlFor:"token-name",children:"Name"}),(0,r.jsx)(U,{id:"token-name",name:"name",defaultValue:a?.name??"",required:!0}),(0,r.jsx)(D,{htmlFor:"token-scope",children:"Scope"}),(0,r.jsxs)(L,{id:"token-scope",name:"scope",defaultValue:a?.scope??"read",disabled:a?.kind==="svc",children:[(0,r.jsx)("option",{value:"read",children:"Install and download"}),(0,r.jsx)("option",{value:"write",children:"Include publish permission"}),(0,r.jsx)("option",{value:"full",children:"Include grants, sources and audit access"})]}),(0,r.jsx)(D,{htmlFor:"token-lifetime",children:"Lifetime"}),(0,r.jsx)(L,{id:"token-lifetime",name:"lifetimeDays",defaultValue:u?.defaultDays,required:!0,children:u===void 0?null:ie(u).map(i=>(0,r.jsx)("option",{value:i,children:J(i)},i))}),n?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(D,{htmlFor:"token-project-mode",children:"Projects"}),(0,r.jsxs)(L,{id:"token-project-mode",name:"projectMode",defaultValue:a?.projectMode??"all",children:[(0,r.jsx)("option",{value:"all",children:"All accessible projects"}),(0,r.jsx)("option",{value:"selected",children:"Selected projects"})]}),(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{children:"Choose projects again when renewing a selected token"}),e.projects.map(i=>(0,r.jsxs)("label",{className:"flex min-h-11 items-center gap-2",children:[(0,r.jsx)("input",{type:"checkbox",name:"projectIds",value:i.id}),i.name]},i.id))]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(D,{htmlFor:"token-principal",children:"Service principal"}),(0,r.jsxs)(L,{id:"token-principal",name:"principal",defaultValue:a?.servicePrincipalId??"",disabled:a?.kind==="svc",required:a?.kind!=="svc",children:[(0,r.jsx)("option",{value:"",disabled:!0,children:"Select a principal"}),s.filter(i=>i.projectId===k).map(i=>(0,r.jsx)("option",{value:i.id,children:i.name},i.id))]}),e.principalsRestricted?(0,r.jsx)("p",{children:"Ask an organization administrator to create a service identity for this project."}):null]}),a?.kind!=="svc"?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(D,{htmlFor:"token-overlap",children:"Overlap"}),(0,r.jsxs)(L,{id:"token-overlap",name:"overlap",defaultValue:"0",children:[(0,r.jsx)("option",{value:"0",children:"None"}),(0,r.jsx)("option",{value:"1",children:"1 day"}),(0,r.jsx)("option",{value:"7",children:"7 days"})]}),(0,r.jsx)("p",{children:"The old token stops at the end of the overlap or when the new token expires, whichever is first."})]}),(0,r.jsx)(C,{type:"submit",disabled:e.busy||e.loading||u===void 0,children:a===null?"Issue token":"Renew token"}),a===null?null:(0,r.jsx)(C,{type:"button",variant:"outline",disabled:e.busy,onClick:()=>t.closeSecret(),children:"Cancel renewal"})]},`${e.target}:${a?.id??""}:${u?.defaultDays}`)]},`${e.target}:${a?.id??""}`),(0,r.jsx)(D,{htmlFor:"token-list",children:"Token list"}),(0,r.jsxs)(L,{id:"token-list",value:e.target,disabled:e.busy,onChange:i=>{t.selectTarget(i.target.value,e.project)},children:[(0,r.jsx)("option",{value:"personal",children:"My personal tokens"}),e.project===null?null:(0,r.jsx)("option",{value:"project",children:"Project tokens"}),(0,r.jsx)("option",{value:"organization",children:"Organization tokens"})]}),(0,r.jsxs)("details",{className:"detail-group",children:[(0,r.jsx)("summary",{children:"How token access works"}),(0,r.jsx)("p",{children:"Personal tokens use your access and stop working if you leave or your account is suspended. Service tokens use a service identity and keep working when their creator leaves. Each project's access policy can limit a token further."})]}),(0,r.jsx)(Qe,{state:e,controller:t},`${e.target}:${e.project}`),e.project===null&&e.organizationPermissions.includes("org:service-principals:write")?(0,r.jsx)(we,{controller:t.trustedPublishers,permissions:e.organizationPermissions}):null,(0,r.jsxs)("details",{className:"detail-group",children:[(0,r.jsx)("summary",{className:"min-h-11 cursor-pointer font-semibold",children:"Service principals"}),(0,r.jsx)(Ce,{state:e,controller:t}),(0,r.jsx)(C,{type:"button",variant:"outline",disabled:e.busy,onClick:()=>{t.loadPrincipals()},children:"Reload service principals"}),e.principalsRestricted?(0,r.jsx)(F,{kind:"placeholder",title:"You cannot browse service principals here."}):e.principalsLoading?(0,r.jsx)(F,{kind:"loading",title:"Loading service principals\u2026"}):e.principals.length===0?(0,r.jsx)(F,{kind:"empty",title:"No service principals loaded."}):(0,r.jsx)(Q,{label:"Service principals",items:e.principals,columns:[{key:"name",label:"Name",value:i=>i.name,render:i=>(0,r.jsxs)("div",{className:"grid gap-1",children:[(0,r.jsx)("strong",{children:i.name}),(0,r.jsx)(ne,{value:i.id,label:"principal ID"})]})},{key:"status",label:"Status",value:i=>i.status,render:i=>(0,r.jsx)(ae,{status:i.status})},{key:"actions",label:"Actions",value:()=>"",sortable:!1,render:i=>(0,r.jsx)(G,{action:"Revoke principal access",target:`${i.name} (${i.id})`,scope:i.projectId===null?"Organization":`Project: ${e.projectSlugs[i.projectId]??i.projectId}`,description:"Suspending this principal stops all of its tokens from working. Update clients before continuing.",disabled:e.busy||i.status!=="active",onConfirm:()=>{t.suspendPrincipal(i)}},`${i.id}:${i.status}`)}]}),e.principalsNext===null?null:(0,r.jsx)(C,{type:"button",disabled:e.busy,onClick:()=>{t.loadPrincipals(e.principalsNext)},children:"Next service principals"})]})]})}function tt(e,t,n){let u=()=>{e.navigate(),n()},a=()=>e.navigate(),p=k=>{a(),k.persisted===!0&&(n(),e.snapshot().organizationPermissions.includes("org:service-principals:write")&&e.trustedPublishers.load())};return t.addEventListener("hashchange",u),t.addEventListener("pagehide",a),t.addEventListener("pageshow",p),()=>{t.removeEventListener("hashchange",u),t.removeEventListener("pagehide",a),t.removeEventListener("pageshow",p),e.dispose()}}function nt(e,t){return t.subscribeReplay?.(n=>{n.ok&&(/^\/_pb\/(?:me\/)?tokens\/[^/]+$/.test(n.path)||/^\/_pb\/projects\/[^/]+\/tokens\/[^/]+$/.test(n.path)||/^\/_pb\/service-principals(?:\/[^/]+\/suspend)?$/.test(n.path)||/^\/_pb\/projects\/[^/]+\/service-principals\/[^/]+\/suspend$/.test(n.path))&&(e.load(),e.loadPrincipals())})}function Wt(){let e=ye(),t=(0,M.useMemo)(()=>Ye(e,{storage:{getItem:u=>window.sessionStorage.getItem(u),setItem:(u,a)=>window.sessionStorage.setItem(u,a),removeItem:u=>window.sessionStorage.removeItem(u)},origin:window.location.origin,clipboard:u=>navigator.clipboard.writeText(u),navigate:u=>{window.location.hash=u},newKey:()=>crypto.randomUUID(),now:Date.now}),[e]),n=(0,M.useSyncExternalStore)(t.subscribe,t.snapshot,t.snapshot);return(0,M.useEffect)(()=>{function u(){let p=new URLSearchParams(window.location.hash.split("?")[1]??"").get("project");window.location.hash.startsWith("#/tokens")&&t.start(p===null?"personal":"project",p)}function a(){window.location.hash.startsWith("#/tokens")&&(t.identity(),t.loadPrincipals())}return u(),t.identity(),t.loadPrincipals(),tt(t,window,()=>{u(),a()})},[t]),(0,M.useEffect)(()=>nt(t,e),[t,e]),(0,r.jsx)(et,{state:n,controller:t})}export{Qe as TokenList,Wt as TokensPage,et as TokensView,tt as bindTokensLifecycle,nt as bindTokensReplay,Ye as createTokensController,J as dayLabel,Je as filterTokens,pe as hasSetupAccess,Ae as inResultScope,ie as lifetimeChoices,He as tokensReducer};
package/dist/auth.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type ReactNode } from 'react';
1
2
  import type { ApiClient, ApiErrorCode, ApiRequestDescription } from './api.js';
2
3
  import type { paths } from './api-types.js';
3
4
  import { type PendingAction, type PendingStorage, type PendingDisplay } from './pending.js';
@@ -16,7 +17,7 @@ export type SsoOutcome = 'navigated' | 'refused' | 'failed';
16
17
  export declare function startSso(client: AuthClient, provider: string, purpose: 'login' | 'reauth', navigate: (location: string) => void, hash?: string): Promise<SsoOutcome>;
17
18
  export interface LoginState {
18
19
  readonly status: 'idle' | 'busy' | 'signed-in' | 'error';
19
- readonly error: 'invalid' | 'unavailable' | null;
20
+ readonly error: 'invalid' | 'unavailable' | 'disabled' | null;
20
21
  }
21
22
  export interface LoginInput {
22
23
  readonly email: string;
@@ -65,12 +66,12 @@ export declare function createReauthFlow(deps: {
65
66
  submitLocal(input: {
66
67
  password: string;
67
68
  code: string;
68
- }): Promise<"done" | "refused">;
69
+ }): Promise<"done" | "refused" | "disabled">;
69
70
  };
70
71
  export type SetupNotice = 'bad_token_shape' | 'token_refused' | 'origin_refused' | 'rate_limited' | 'unavailable' | 'password_mismatch' | 'missing_fields' | 'finish_refused';
71
72
  export declare const SETUP_NOTICE_TEXT: Readonly<Record<SetupNotice, string>>;
72
73
  export interface SetupState {
73
- readonly stage: 'token' | 'enroll' | 'done' | 'uncertain';
74
+ readonly stage: 'token' | 'enroll' | 'done' | 'uncertain' | 'disabled';
74
75
  readonly busy: boolean;
75
76
  readonly notice: SetupNotice | null;
76
77
  readonly enrollment: {
@@ -103,10 +104,17 @@ export interface ShellServices {
103
104
  }
104
105
  export declare const ServicesContext: import("react").Context<ShellServices | null>;
105
106
  export declare function useServices(): ShellServices;
107
+ export declare function ssoFailureMessage(reason: string | null): string;
108
+ export declare function SigninFailedView(props: {
109
+ reason: string | null;
110
+ signedIn: boolean;
111
+ hash?: string;
112
+ }): import("react").JSX.Element;
106
113
  export declare function LoginView(props: {
107
114
  state: LoginState;
108
115
  providers: readonly AuthProvider[];
109
116
  local: boolean;
117
+ availability?: 'loading' | 'ready' | 'error';
110
118
  ssoError?: 'refused' | 'failed' | null;
111
119
  onSubmit: (input: LoginInput) => void;
112
120
  onSso: (provider: string) => void;
@@ -114,6 +122,7 @@ export declare function LoginView(props: {
114
122
  export declare function ReauthView(props: {
115
123
  providers: readonly AuthProvider[];
116
124
  local: boolean;
125
+ availability?: 'loading' | 'ready' | 'error';
117
126
  error: boolean;
118
127
  busy: boolean;
119
128
  onSubmit: (input: {
@@ -148,13 +157,24 @@ export declare function SetupView(props: {
148
157
  }) => void;
149
158
  }): import("react").JSX.Element;
150
159
  export declare function useProviders(client: AuthClient): {
160
+ client: AuthClient;
151
161
  providers: AuthProvider[];
152
162
  local: boolean;
163
+ availability: "loading" | "ready" | "error";
164
+ } | {
165
+ providers: never[];
166
+ local: boolean;
167
+ availability: "loading";
153
168
  };
154
169
  export declare function LoginScreen(props: {
155
170
  client: AuthClient;
156
171
  onSignedIn: () => void;
157
172
  }): import("react").JSX.Element;
173
+ export declare function SetupAvailabilityView(props: {
174
+ availability: 'loading' | 'ready' | 'error';
175
+ local: boolean;
176
+ providers: readonly AuthProvider[];
177
+ }): import("react").JSX.Element;
158
178
  export declare function SetupScreen(props: {
159
179
  client: AuthClient;
160
180
  onSignedIn: () => void;
@@ -167,4 +187,7 @@ export declare function ReauthScreen(props: {
167
187
  export declare function ReauthConfirm(props: {
168
188
  flow: ReturnType<typeof createReauthFlow>;
169
189
  }): import("react").JSX.Element;
190
+ export declare function AuthLayout({ children }: {
191
+ children: ReactNode;
192
+ }): import("react").JSX.Element;
170
193
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,qBAAqB,EAAa,MAAM,UAAU,CAAC;AAC1F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBlD,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AAE1C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AA6BD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAmB7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBjD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5D,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,GAAG,QAAQ,EAC3B,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EACpC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