ocean-brain 0.7.4 → 0.7.5

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 (53) hide show
  1. package/package.json +1 -1
  2. package/server/client/dist/assets/{Calendar-Bz7jheg6.js → Calendar-Bc2zJueR.js} +1 -1
  3. package/server/client/dist/assets/{Callout-DlFLkTCG.js → Callout-B4kA_Cvr.js} +1 -1
  4. package/server/client/dist/assets/{Graph-BdxtJvog.js → Graph-uq5jfJgt.js} +1 -1
  5. package/server/client/dist/assets/{Image.es-BFodqKS5.js → Image.es-BpAOJjJT.js} +1 -1
  6. package/server/client/dist/assets/{Note-BgMxsWZT.js → Note-Bo8ZYRP-.js} +1 -1
  7. package/server/client/dist/assets/{Plus.es-Yq7J1Ur4.js → Plus.es-Dc_js8AC.js} +1 -1
  8. package/server/client/dist/assets/{Reminders-CUsR56ff.js → Reminders-lj7Equld.js} +1 -1
  9. package/server/client/dist/assets/{Search-DncrGgOZ.js → Search-1wcRO5--.js} +1 -1
  10. package/server/client/dist/assets/{SurfaceCard-CfL1jD-O.js → SurfaceCard-CkAVMLPs.js} +1 -1
  11. package/server/client/dist/assets/{Tag-CKDLs2Y6.js → Tag-CeygwFfv.js} +1 -1
  12. package/server/client/dist/assets/{TagNotes-ByX_Qias.js → TagNotes-B8DqItxw.js} +1 -1
  13. package/server/client/dist/assets/{Trash.es-BPrF6TPV.js → Trash.es-OuQVb_SX.js} +1 -1
  14. package/server/client/dist/assets/{ViewNotes-r1kxKZ8O.js → ViewNotes-BH7PbdOD.js} +1 -1
  15. package/server/client/dist/assets/{ViewSectionTableRenderer-DQ4UeCnm.js → ViewSectionTableRenderer-BJwhd5be.js} +1 -1
  16. package/server/client/dist/assets/{Views-FzFBtNT2.js → Views-eYFtsdFj.js} +1 -1
  17. package/server/client/dist/assets/{image.api-Bcg3TFCG.js → image.api-C0eYGCeH.js} +1 -1
  18. package/server/client/dist/assets/{index-DiMt3Dz4.js → index-D3BfroIT.js} +1 -1
  19. package/server/client/dist/assets/{index-BFfQKAUY.js → index-jIfkRdY_.js} +42 -42
  20. package/server/client/dist/assets/{manage-image-DzDlncCM.js → manage-image-C0YwkLIP.js} +1 -1
  21. package/server/client/dist/assets/{manage-image-detail-Bqw8NURO.js → manage-image-detail-C8Q7K7I3.js} +1 -1
  22. package/server/client/dist/assets/{mcp-BqasqTWC.js → mcp-DHHhTLC8.js} +1 -1
  23. package/server/client/dist/assets/{placeholder-Ro00byT7.js → placeholder-Cr_nI8UI.js} +1 -1
  24. package/server/client/dist/assets/{properties-Tid6-ghT.js → properties-CvYWJWUM.js} +1 -1
  25. package/server/client/dist/assets/{trash-bHK02-Up.js → trash-DA27aW7L.js} +1 -1
  26. package/server/client/dist/assets/{useReminderMutate-BWymIujb.js → useReminderMutate-CDmIEwsw.js} +1 -1
  27. package/server/client/dist/index.html +1 -1
  28. package/server/dist/app.js +2 -2
  29. package/server/dist/app.js.map +1 -1
  30. package/server/dist/features/auth/http/api.js +5 -1
  31. package/server/dist/features/auth/http/api.js.map +1 -1
  32. package/server/dist/features/auth/http/pages.js +8 -1
  33. package/server/dist/features/auth/http/pages.js.map +1 -1
  34. package/server/dist/features/auth/service.js +16 -7
  35. package/server/dist/features/auth/service.js.map +1 -1
  36. package/server/dist/modules/auth-guard.js +21 -2
  37. package/server/dist/modules/auth-guard.js.map +1 -1
  38. package/server/dist/modules/auth-redirect.js +10 -0
  39. package/server/dist/modules/auth-redirect.js.map +1 -0
  40. package/server/dist/modules/rate-limit.js +15 -1
  41. package/server/dist/modules/rate-limit.js.map +1 -1
  42. package/server/dist/modules/server-events-handler.js +17 -0
  43. package/server/dist/modules/server-events-handler.js.map +1 -1
  44. package/server/dist/modules/session-store.js +149 -0
  45. package/server/dist/modules/session-store.js.map +1 -0
  46. package/server/dist/routes/api.js +44 -19
  47. package/server/dist/routes/api.js.map +1 -1
  48. package/server/dist/routes/auth-pages.js +13 -2
  49. package/server/dist/routes/auth-pages.js.map +1 -1
  50. package/server/dist/routes/client.js +12 -2
  51. package/server/dist/routes/client.js.map +1 -1
  52. package/server/dist/routes/graphql.js +23 -19
  53. package/server/dist/routes/graphql.js.map +1 -1
@@ -1 +1 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{a6 as L,q as T,y as G,k as S,ah as C,a0 as F,P as N,J as k,L as q,aY as B,T as O,B as D,a1 as z,i as h,j as K,aO as Q}from"./index-BFfQKAUY.js";import{f as U,d as W}from"./image.api-Bcg3TFCG.js";import{a as x}from"./graph-vendor-CUxe67Lr.js";import{I as H}from"./Image-DxWhlIDG.js";import{S as M}from"./SurfaceCard-CfL1jD-O.js";import{c as $,n as J}from"./Trash.es-BPrF6TPV.js";import"./note-core-Z6kqulGB.js";const V=n=>{const{data:a}=L({queryKey:T.images.list(n.searchParams),async queryFn(){const s=await U({offset:n.searchParams.offset,limit:n.searchParams.limit});if(s.type==="error")throw s;return s.allImages}});return n.render(a)},b=16;function X(n,a,s){return Math.max(Math.floor((Math.max(n,0)+s)/(a+s)),1)}function _(n,a,s){return n*a+(n-1)*s}function Y({minItemWidth:n,gap:a,rows:s,fallback:l,override:g}){const[i,w]=x.useState(null),[v,p]=x.useState(l??s),r=x.useRef(null),o=x.useCallback(t=>{w(t)},[]),d=g==null,y=d?v:g;return x.useLayoutEffect(()=>{if(!d){r.current=null;return}if(!i){r.current=null,p(c=>c===(l??s)?c:l??s);return}let t=null;const I=()=>{const c=i.offsetWidth,E=X(c,n,a),u=r.current;let j=E;if(u!==null&&u!==E)if(E>u){const f=_(u+1,n,a);c<f+b&&(j=u)}else{const f=_(u,n,a);c>f-b&&(j=u)}r.current=j;const A=Math.max(j*s,s);p(f=>f===A?f:A)},m=()=>{t===null&&(t=window.requestAnimationFrame(()=>{t=null,I()}))};if(m(),typeof ResizeObserver<"u"){const c=new ResizeObserver(()=>{m()});return c.observe(i),()=>{c.disconnect(),t!==null&&window.cancelAnimationFrame(t)}}return window.addEventListener("resize",m),window.addEventListener("orientationchange",m),()=>{window.removeEventListener("resize",m),window.removeEventListener("orientationchange",m),t!==null&&window.cancelAnimationFrame(t)}},[i,l,a,d,n,s]),{containerRef:o,limit:y,isAutoLimit:d}}const Z=240,ee=20,te=4,R=192,P=K(Q),de=()=>{const n=G(),a=S(),s=P.useNavigate(),{page:l}=P.useSearch(),{containerRef:g,limit:i}=Y({minItemWidth:Z,gap:ee,rows:te}),w=C({mutationFn:W,onSuccess:r=>{if(r.type==="error")throw r;a.invalidateQueries({queryKey:T.images.listAll(),exact:!1})}}),v=async r=>{await n("Delete this image? It is not referenced by any notes.")&&w.mutate(r)},p=r=>r===1?"1 reference":`${r} references`;return e.jsx("div",{ref:g,children:e.jsx(F,{fallback:e.jsx(N,{title:"Images",variant:"default",heading:e.jsx(h,{width:136,height:24,className:"rounded-full"}),description:e.jsx(h,{width:232,height:16,className:"rounded-full"}),children:e.jsx("div",{className:"flex flex-col gap-4",children:e.jsx("div",{className:"grid-auto-cards grid gap-4",children:Array.from({length:3},(r,o)=>e.jsxs(M,{flush:!0,children:[e.jsx("div",{className:"flex items-center justify-center bg-muted/25 p-3",style:{height:R},children:e.jsx(h,{width:"100%",height:R-24,className:"rounded-[12px]"})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border-subtle px-3 py-2.5",children:[e.jsx(h,{width:92,height:14,className:"rounded-full"}),e.jsx(h,{width:32,height:32,className:"rounded-[12px]"})]})]},o))})})}),errorTitle:"Failed to load images",errorDescription:"Retry loading uploaded image metadata",resetKeys:[l,i],children:e.jsx(V,{searchParams:{offset:(l-1)*i,limit:i},render:({images:r,totalCount:o})=>{const d=o>0?`Images (${o})`:void 0,y="Review and manage the images you uploaded inside notes";return r.length===0?e.jsx(N,{title:"Images",variant:"default",heading:d,description:y,children:e.jsx(k,{title:"There are no images",description:"Upload an image in any note and it will appear here"})}):e.jsx(N,{title:"Images",variant:"default",heading:d,description:y,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid-auto-cards grid gap-4",children:r.map(t=>e.jsxs(M,{flush:!0,children:[e.jsx(q,{to:B,params:{id:t.id},className:"focus-ring-soft block overflow-hidden rounded-t-[18px] outline-none",children:e.jsx("div",{className:"flex items-center justify-center bg-muted/25 p-3",style:{height:R},children:e.jsx(H,{className:"h-full w-full rounded-[12px] object-contain transition-transform duration-200 hover:scale-[1.02]",src:t.url,alt:t.id})})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border-subtle px-3 py-2.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-fg-secondary",children:[e.jsx($,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),e.jsx(O,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:"truncate",children:p(t.referenceCount)})]}),e.jsx(D,{variant:"ghost",size:"icon-sm",disabled:t.referenceCount>0,onClick:()=>v(t.id),children:e.jsx(J,{className:"h-4 w-4"})})]})]},t.id))}),o&&i<o&&e.jsx(z,{page:l,last:Math.ceil(o/i),onChange:t=>{s({search:I=>({...I,page:t})})}})]})})}})})})};export{de as default};
1
+ import{j as e}from"./note-vendor-i1M2FSI2.js";import{a6 as L,q as T,y as G,k as S,ah as C,a0 as F,P as N,J as k,L as q,aY as B,T as O,B as D,a1 as z,i as h,j as K,aO as Q}from"./index-jIfkRdY_.js";import{f as U,d as W}from"./image.api-C0eYGCeH.js";import{a as x}from"./graph-vendor-CUxe67Lr.js";import{I as H}from"./Image-DxWhlIDG.js";import{S as M}from"./SurfaceCard-CkAVMLPs.js";import{c as $,n as J}from"./Trash.es-OuQVb_SX.js";import"./note-core-Z6kqulGB.js";const V=n=>{const{data:a}=L({queryKey:T.images.list(n.searchParams),async queryFn(){const s=await U({offset:n.searchParams.offset,limit:n.searchParams.limit});if(s.type==="error")throw s;return s.allImages}});return n.render(a)},b=16;function X(n,a,s){return Math.max(Math.floor((Math.max(n,0)+s)/(a+s)),1)}function _(n,a,s){return n*a+(n-1)*s}function Y({minItemWidth:n,gap:a,rows:s,fallback:l,override:g}){const[i,w]=x.useState(null),[v,p]=x.useState(l??s),r=x.useRef(null),o=x.useCallback(t=>{w(t)},[]),d=g==null,y=d?v:g;return x.useLayoutEffect(()=>{if(!d){r.current=null;return}if(!i){r.current=null,p(c=>c===(l??s)?c:l??s);return}let t=null;const I=()=>{const c=i.offsetWidth,E=X(c,n,a),u=r.current;let j=E;if(u!==null&&u!==E)if(E>u){const f=_(u+1,n,a);c<f+b&&(j=u)}else{const f=_(u,n,a);c>f-b&&(j=u)}r.current=j;const A=Math.max(j*s,s);p(f=>f===A?f:A)},m=()=>{t===null&&(t=window.requestAnimationFrame(()=>{t=null,I()}))};if(m(),typeof ResizeObserver<"u"){const c=new ResizeObserver(()=>{m()});return c.observe(i),()=>{c.disconnect(),t!==null&&window.cancelAnimationFrame(t)}}return window.addEventListener("resize",m),window.addEventListener("orientationchange",m),()=>{window.removeEventListener("resize",m),window.removeEventListener("orientationchange",m),t!==null&&window.cancelAnimationFrame(t)}},[i,l,a,d,n,s]),{containerRef:o,limit:y,isAutoLimit:d}}const Z=240,ee=20,te=4,R=192,P=K(Q),de=()=>{const n=G(),a=S(),s=P.useNavigate(),{page:l}=P.useSearch(),{containerRef:g,limit:i}=Y({minItemWidth:Z,gap:ee,rows:te}),w=C({mutationFn:W,onSuccess:r=>{if(r.type==="error")throw r;a.invalidateQueries({queryKey:T.images.listAll(),exact:!1})}}),v=async r=>{await n("Delete this image? It is not referenced by any notes.")&&w.mutate(r)},p=r=>r===1?"1 reference":`${r} references`;return e.jsx("div",{ref:g,children:e.jsx(F,{fallback:e.jsx(N,{title:"Images",variant:"default",heading:e.jsx(h,{width:136,height:24,className:"rounded-full"}),description:e.jsx(h,{width:232,height:16,className:"rounded-full"}),children:e.jsx("div",{className:"flex flex-col gap-4",children:e.jsx("div",{className:"grid-auto-cards grid gap-4",children:Array.from({length:3},(r,o)=>e.jsxs(M,{flush:!0,children:[e.jsx("div",{className:"flex items-center justify-center bg-muted/25 p-3",style:{height:R},children:e.jsx(h,{width:"100%",height:R-24,className:"rounded-[12px]"})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border-subtle px-3 py-2.5",children:[e.jsx(h,{width:92,height:14,className:"rounded-full"}),e.jsx(h,{width:32,height:32,className:"rounded-[12px]"})]})]},o))})})}),errorTitle:"Failed to load images",errorDescription:"Retry loading uploaded image metadata",resetKeys:[l,i],children:e.jsx(V,{searchParams:{offset:(l-1)*i,limit:i},render:({images:r,totalCount:o})=>{const d=o>0?`Images (${o})`:void 0,y="Review and manage the images you uploaded inside notes";return r.length===0?e.jsx(N,{title:"Images",variant:"default",heading:d,description:y,children:e.jsx(k,{title:"There are no images",description:"Upload an image in any note and it will appear here"})}):e.jsx(N,{title:"Images",variant:"default",heading:d,description:y,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid-auto-cards grid gap-4",children:r.map(t=>e.jsxs(M,{flush:!0,children:[e.jsx(q,{to:B,params:{id:t.id},className:"focus-ring-soft block overflow-hidden rounded-t-[18px] outline-none",children:e.jsx("div",{className:"flex items-center justify-center bg-muted/25 p-3",style:{height:R},children:e.jsx(H,{className:"h-full w-full rounded-[12px] object-contain transition-transform duration-200 hover:scale-[1.02]",src:t.url,alt:t.id})})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border-subtle px-3 py-2.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-fg-secondary",children:[e.jsx($,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),e.jsx(O,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:"truncate",children:p(t.referenceCount)})]}),e.jsx(D,{variant:"ghost",size:"icon-sm",disabled:t.referenceCount>0,onClick:()=>v(t.id),children:e.jsx(J,{className:"h-4 w-4"})})]})]},t.id))}),o&&i<o&&e.jsx(z,{page:l,last:Math.ceil(o/i),onChange:t=>{s({search:I=>({...I,page:t})})}})]})})}})})})};export{de as default};
@@ -1 +1 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{p as D,T as r,t as F,L as p,N as _,ad as R,aZ as Z,aO as E,f as q,a0 as B,j as G,aY as L,y as O,k as z,a6 as b,q as x,a_ as H,ah as v,a$ as K,b0 as P,B as w,i as l,m as Q}from"./index-BFfQKAUY.js";import{a as U,d as $}from"./image.api-Bcg3TFCG.js";import{a as t}from"./graph-vendor-CUxe67Lr.js";import{I as V}from"./Image-DxWhlIDG.js";import{S as g}from"./SurfaceCard-CfL1jD-O.js";import{c as W,n as Y}from"./Trash.es-BPrF6TPV.js";import{I as J}from"./Image.es-BFodqKS5.js";import"./note-core-Z6kqulGB.js";const X=new Map([["bold",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,36c-20.09,0-37.92,7.93-50,21.56C115.92,43.93,98.09,36,78,36a66.08,66.08,0,0,0-66,66c0,72.34,105.81,130.14,110.31,132.57a12,12,0,0,0,11.38,0C138.19,232.14,244,174.34,244,102A66.08,66.08,0,0,0,178,36Zm-5.49,142.36A328.69,328.69,0,0,1,128,210.16a328.69,328.69,0,0,1-44.51-31.8C61.82,159.77,36,131.42,36,102A42,42,0,0,1,78,60c17.8,0,32.7,9.4,38.89,24.54a12,12,0,0,0,22.22,0C145.3,69.4,160.2,60,178,60a42,42,0,0,1,42,42C220,131.42,194.18,159.77,172.51,178.36Z"}))],["duotone",t.createElement(t.Fragment,null,t.createElement("path",{d:"M232,102c0,66-104,122-104,122S24,168,24,102A54,54,0,0,1,78,48c22.59,0,41.94,12.31,50,32,8.06-19.69,27.41-32,50-32A54,54,0,0,1,232,102Z",opacity:"0.2"}),t.createElement("path",{d:"M178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,70,103.79,126.66,108.21,129a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40ZM128,214.8C109.74,204.16,32,155.69,32,102A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46C224,155.61,146.24,204.15,128,214.8Z"}))],["fill",t.createElement(t.Fragment,null,t.createElement("path",{d:"M240,102c0,70-103.79,126.66-108.21,129a8,8,0,0,1-7.58,0C119.79,228.66,16,172,16,102A62.07,62.07,0,0,1,78,40c20.65,0,38.73,8.88,50,23.89C139.27,48.88,157.35,40,178,40A62.07,62.07,0,0,1,240,102Z"}))],["light",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,42c-21,0-39.26,9.47-50,25.34C117.26,51.47,99,42,78,42a60.07,60.07,0,0,0-60,60c0,29.2,18.2,59.59,54.1,90.31a334.68,334.68,0,0,0,53.06,37,6,6,0,0,0,5.68,0,334.68,334.68,0,0,0,53.06-37C219.8,161.59,238,131.2,238,102A60.07,60.07,0,0,0,178,42ZM128,217.11C111.59,207.64,30,157.72,30,102A48.05,48.05,0,0,1,78,54c20.28,0,37.31,10.83,44.45,28.27a6,6,0,0,0,11.1,0C140.69,64.83,157.72,54,178,54a48.05,48.05,0,0,1,48,48C226,157.72,144.41,207.64,128,217.11Z"}))],["regular",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,70,103.79,126.66,108.21,129a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40ZM128,214.8C109.74,204.16,32,155.69,32,102A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46C224,155.61,146.24,204.15,128,214.8Z"}))],["thin",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,44c-21.44,0-39.92,10.19-50,27.07C117.92,54.19,99.44,44,78,44a58.07,58.07,0,0,0-58,58c0,28.59,18,58.47,53.4,88.79a333.81,333.81,0,0,0,52.7,36.73,4,4,0,0,0,3.8,0,333.81,333.81,0,0,0,52.7-36.73C218,160.47,236,130.59,236,102A58.07,58.07,0,0,0,178,44ZM128,219.42c-14-8-100-59.35-100-117.42A50.06,50.06,0,0,1,78,52c21.11,0,38.85,11.31,46.3,29.51a4,4,0,0,0,7.4,0C139.15,63.31,156.89,52,178,52a50.06,50.06,0,0,1,50,50C228,160,142,211.46,128,219.42Z"}))]]),A=t.forwardRef((a,n)=>t.createElement(D,{ref:n,...a,weights:X}));A.displayName="HeartIcon";const ee=A;function ae({name:a}){return e.jsx(r,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center rounded-full border border-border-subtle bg-hover-subtle px-2.5 py-1",children:a})}function se({id:a,title:n,tags:i,createdAt:u,updatedAt:d}){const o=new Date(Number(u)),m=F(Number(d));return e.jsx("div",{className:"border-b-2 border-dashed border-border-subtle last:border-b-0",children:e.jsxs("div",{className:"py-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{variant:"label",weight:"medium",tone:"tertiary",children:m}),e.jsxs(r,{variant:"label",tone:"placeholder",children:["(",o.toDateString(),")"]})]}),e.jsx(r,{as:"div",variant:"body",weight:"bold",tracking:"tight",children:e.jsx(p,{className:"transition-colors hover:text-accent-primary",to:_,params:{id:a},children:n||"Untitled"})}),i&&i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(c=>e.jsx(p,{to:R,params:{id:c.id},search:{page:1},children:e.jsx(ae,{name:c.name})},c.id))})]})})}const I=G(L),j=352,te="mb-4 inline-flex items-center gap-1 text-fg-secondary transition-colors hover:text-fg-default",T="flex items-center justify-center bg-muted/25 p-3",re="h-full w-full rounded-[12px] object-contain",M="mb-3 flex flex-wrap items-start justify-between gap-3 border-b border-border-subtle pb-3",S="space-y-1",ne=a=>a===1?"1 reference":`${a} references`,C=(a,n)=>typeof a=="object"&&a!==null&&"errors"in a&&Array.isArray(a.errors)&&typeof a.errors[0]?.message=="string"?a.errors[0].message:a instanceof Error&&a.message?a.message:n,ie=()=>e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row",children:[e.jsx("div",{className:"w-full lg:w-[400px] lg:flex-shrink-0",children:e.jsxs(g,{flush:!0,children:[e.jsx("div",{className:T,style:{height:j},children:e.jsx(l,{width:"100%",height:j-24,className:"rounded-[12px]"})}),e.jsxs("div",{className:"flex flex-col gap-4 border-t border-border-subtle p-4",children:[e.jsx(l,{width:96,height:14,className:"rounded-full"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{height:32,className:"flex-1 rounded-[12px]"}),e.jsx(l,{height:32,className:"flex-1 rounded-[12px]"})]})]})]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs(g,{children:[e.jsxs("div",{className:M,children:[e.jsxs("div",{className:S,children:[e.jsx(l,{width:140,height:18}),e.jsx(l,{width:220,height:14,className:"rounded-full"})]}),e.jsx(l,{width:84,height:14,className:"rounded-full"})]}),e.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:3},(a,n)=>e.jsx(l,{height:72,className:"rounded-[16px]"},n))})]})})]}),le=({id:a})=>{const n=O(),i=Q(),u=I.useNavigate(),d=z(),{data:o}=b({queryKey:x.images.detail(a),queryFn:async()=>{const s=await U(a);if(s.type==="error")throw s;return s.image}}),{data:m}=b({queryKey:x.images.notes(a),queryFn:async()=>{const s=await H(o.url);if(s.type==="error")throw s;return s.imageNotes}}),c=m.length,y=ne(c),h=c===0,f=v({mutationFn:async()=>{const s=await $(a);if(s.type==="error")throw s;if(!s.deleteImage)throw new Error("Failed to delete image");return s.deleteImage},onSuccess:async()=>{await d.invalidateQueries({queryKey:x.images.listAll(),exact:!1}),i("Image deleted"),u({to:E,search:{page:1}})},onError:s=>{i(C(s,"Failed to delete image"))}}),N=v({mutationFn:async()=>{const s=await K("heroBanner",o.url);if(s.type==="error")throw s},onSuccess:async()=>{await d.invalidateQueries({queryKey:x.ui.heroBanner(),exact:!0}),i("Hero banner updated")},onError:s=>{i(C(s,"Failed to update hero banner"))}}),k=async()=>{!h||f.isPending||await n("Delete this image? It is not referenced by any notes.")&&f.mutate()};return e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row",children:[e.jsx("div",{className:"w-full lg:w-[400px] lg:flex-shrink-0",children:e.jsxs(g,{flush:!0,children:[e.jsx("div",{className:T,style:{height:j},children:e.jsx(V,{className:re,src:o.url,alt:`Image ${o.id}`})}),e.jsxs("div",{className:"flex flex-col gap-4 border-t border-border-subtle p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:14,className:"text-fg-tertiary"}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:y})]}),e.jsx(r,{as:"p",variant:"meta",tone:"tertiary",children:h?"Delete is available because no notes reference this image":"Remove this image from notes before deleting it"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{content:h?"Delete this image":"Cannot delete while referenced by notes",side:"bottom",children:e.jsxs(w,{variant:"soft-danger",size:"sm",className:"flex-1",disabled:!h,isLoading:f.isPending,onClick:k,children:[e.jsx(Y,{size:16}),"Delete"]})}),e.jsxs(w,{variant:"primary",size:"sm",className:"flex-1",isLoading:N.isPending,onClick:()=>N.mutate(),children:[e.jsx(ee,{size:16}),"Set hero banner"]})]})]})]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs(g,{children:[e.jsxs("div",{className:M,children:[e.jsxs("div",{className:S,children:[e.jsx(r,{as:"h2",variant:"subheading",weight:"medium",tracking:"tight",children:"Referenced Notes"}),e.jsx(r,{as:"p",variant:"meta",tone:"secondary",children:"Notes currently using this image"})]}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:y})]}),c>0?e.jsx("ul",{className:"flex flex-col",children:m.map(s=>e.jsx("li",{children:e.jsx(se,{...s})},s.id))}):e.jsxs("div",{className:"flex items-start gap-3 py-1",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[10px] bg-muted/25 text-fg-disabled",children:e.jsx(J,{size:18})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(r,{as:"p",variant:"body",weight:"medium",tone:"secondary",children:"No notes reference this image"}),e.jsx(r,{as:"p",variant:"meta",tone:"secondary",children:"This image can be deleted or reused in another note"})]})]})]})})]})},pe=()=>{const{id:a}=I.useParams();return e.jsxs(e.Fragment,{children:[e.jsx(Z,{children:e.jsx("title",{children:"Image Detail | Ocean Brain"})}),e.jsxs(p,{to:E,search:{page:1},className:te,children:[e.jsx(q,{size:16}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:"Back to Images"})]}),e.jsx(r,{as:"h1",variant:"heading",weight:"bold",tracking:"tighter",className:"sr-only",children:"Image Detail"}),e.jsx(B,{fallback:e.jsx(ie,{}),errorTitle:"Failed to load image detail",errorDescription:"Retry loading the image preview and its referenced notes",resetKeys:[a],children:e.jsx(le,{id:a})})]})};export{pe as default};
1
+ import{j as e}from"./note-vendor-i1M2FSI2.js";import{p as D,T as r,t as F,L as p,N as _,ad as R,aZ as Z,aO as E,f as q,a0 as B,j as G,aY as L,y as O,k as z,a6 as b,q as x,a_ as H,ah as v,a$ as K,b0 as P,B as w,i as l,m as Q}from"./index-jIfkRdY_.js";import{a as U,d as $}from"./image.api-C0eYGCeH.js";import{a as t}from"./graph-vendor-CUxe67Lr.js";import{I as V}from"./Image-DxWhlIDG.js";import{S as g}from"./SurfaceCard-CkAVMLPs.js";import{c as W,n as Y}from"./Trash.es-OuQVb_SX.js";import{I as J}from"./Image.es-BpAOJjJT.js";import"./note-core-Z6kqulGB.js";const X=new Map([["bold",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,36c-20.09,0-37.92,7.93-50,21.56C115.92,43.93,98.09,36,78,36a66.08,66.08,0,0,0-66,66c0,72.34,105.81,130.14,110.31,132.57a12,12,0,0,0,11.38,0C138.19,232.14,244,174.34,244,102A66.08,66.08,0,0,0,178,36Zm-5.49,142.36A328.69,328.69,0,0,1,128,210.16a328.69,328.69,0,0,1-44.51-31.8C61.82,159.77,36,131.42,36,102A42,42,0,0,1,78,60c17.8,0,32.7,9.4,38.89,24.54a12,12,0,0,0,22.22,0C145.3,69.4,160.2,60,178,60a42,42,0,0,1,42,42C220,131.42,194.18,159.77,172.51,178.36Z"}))],["duotone",t.createElement(t.Fragment,null,t.createElement("path",{d:"M232,102c0,66-104,122-104,122S24,168,24,102A54,54,0,0,1,78,48c22.59,0,41.94,12.31,50,32,8.06-19.69,27.41-32,50-32A54,54,0,0,1,232,102Z",opacity:"0.2"}),t.createElement("path",{d:"M178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,70,103.79,126.66,108.21,129a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40ZM128,214.8C109.74,204.16,32,155.69,32,102A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46C224,155.61,146.24,204.15,128,214.8Z"}))],["fill",t.createElement(t.Fragment,null,t.createElement("path",{d:"M240,102c0,70-103.79,126.66-108.21,129a8,8,0,0,1-7.58,0C119.79,228.66,16,172,16,102A62.07,62.07,0,0,1,78,40c20.65,0,38.73,8.88,50,23.89C139.27,48.88,157.35,40,178,40A62.07,62.07,0,0,1,240,102Z"}))],["light",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,42c-21,0-39.26,9.47-50,25.34C117.26,51.47,99,42,78,42a60.07,60.07,0,0,0-60,60c0,29.2,18.2,59.59,54.1,90.31a334.68,334.68,0,0,0,53.06,37,6,6,0,0,0,5.68,0,334.68,334.68,0,0,0,53.06-37C219.8,161.59,238,131.2,238,102A60.07,60.07,0,0,0,178,42ZM128,217.11C111.59,207.64,30,157.72,30,102A48.05,48.05,0,0,1,78,54c20.28,0,37.31,10.83,44.45,28.27a6,6,0,0,0,11.1,0C140.69,64.83,157.72,54,178,54a48.05,48.05,0,0,1,48,48C226,157.72,144.41,207.64,128,217.11Z"}))],["regular",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,70,103.79,126.66,108.21,129a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40ZM128,214.8C109.74,204.16,32,155.69,32,102A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46C224,155.61,146.24,204.15,128,214.8Z"}))],["thin",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,44c-21.44,0-39.92,10.19-50,27.07C117.92,54.19,99.44,44,78,44a58.07,58.07,0,0,0-58,58c0,28.59,18,58.47,53.4,88.79a333.81,333.81,0,0,0,52.7,36.73,4,4,0,0,0,3.8,0,333.81,333.81,0,0,0,52.7-36.73C218,160.47,236,130.59,236,102A58.07,58.07,0,0,0,178,44ZM128,219.42c-14-8-100-59.35-100-117.42A50.06,50.06,0,0,1,78,52c21.11,0,38.85,11.31,46.3,29.51a4,4,0,0,0,7.4,0C139.15,63.31,156.89,52,178,52a50.06,50.06,0,0,1,50,50C228,160,142,211.46,128,219.42Z"}))]]),A=t.forwardRef((a,n)=>t.createElement(D,{ref:n,...a,weights:X}));A.displayName="HeartIcon";const ee=A;function ae({name:a}){return e.jsx(r,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center rounded-full border border-border-subtle bg-hover-subtle px-2.5 py-1",children:a})}function se({id:a,title:n,tags:i,createdAt:u,updatedAt:d}){const o=new Date(Number(u)),m=F(Number(d));return e.jsx("div",{className:"border-b-2 border-dashed border-border-subtle last:border-b-0",children:e.jsxs("div",{className:"py-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{variant:"label",weight:"medium",tone:"tertiary",children:m}),e.jsxs(r,{variant:"label",tone:"placeholder",children:["(",o.toDateString(),")"]})]}),e.jsx(r,{as:"div",variant:"body",weight:"bold",tracking:"tight",children:e.jsx(p,{className:"transition-colors hover:text-accent-primary",to:_,params:{id:a},children:n||"Untitled"})}),i&&i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(c=>e.jsx(p,{to:R,params:{id:c.id},search:{page:1},children:e.jsx(ae,{name:c.name})},c.id))})]})})}const I=G(L),j=352,te="mb-4 inline-flex items-center gap-1 text-fg-secondary transition-colors hover:text-fg-default",T="flex items-center justify-center bg-muted/25 p-3",re="h-full w-full rounded-[12px] object-contain",M="mb-3 flex flex-wrap items-start justify-between gap-3 border-b border-border-subtle pb-3",S="space-y-1",ne=a=>a===1?"1 reference":`${a} references`,C=(a,n)=>typeof a=="object"&&a!==null&&"errors"in a&&Array.isArray(a.errors)&&typeof a.errors[0]?.message=="string"?a.errors[0].message:a instanceof Error&&a.message?a.message:n,ie=()=>e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row",children:[e.jsx("div",{className:"w-full lg:w-[400px] lg:flex-shrink-0",children:e.jsxs(g,{flush:!0,children:[e.jsx("div",{className:T,style:{height:j},children:e.jsx(l,{width:"100%",height:j-24,className:"rounded-[12px]"})}),e.jsxs("div",{className:"flex flex-col gap-4 border-t border-border-subtle p-4",children:[e.jsx(l,{width:96,height:14,className:"rounded-full"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{height:32,className:"flex-1 rounded-[12px]"}),e.jsx(l,{height:32,className:"flex-1 rounded-[12px]"})]})]})]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs(g,{children:[e.jsxs("div",{className:M,children:[e.jsxs("div",{className:S,children:[e.jsx(l,{width:140,height:18}),e.jsx(l,{width:220,height:14,className:"rounded-full"})]}),e.jsx(l,{width:84,height:14,className:"rounded-full"})]}),e.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:3},(a,n)=>e.jsx(l,{height:72,className:"rounded-[16px]"},n))})]})})]}),le=({id:a})=>{const n=O(),i=Q(),u=I.useNavigate(),d=z(),{data:o}=b({queryKey:x.images.detail(a),queryFn:async()=>{const s=await U(a);if(s.type==="error")throw s;return s.image}}),{data:m}=b({queryKey:x.images.notes(a),queryFn:async()=>{const s=await H(o.url);if(s.type==="error")throw s;return s.imageNotes}}),c=m.length,y=ne(c),h=c===0,f=v({mutationFn:async()=>{const s=await $(a);if(s.type==="error")throw s;if(!s.deleteImage)throw new Error("Failed to delete image");return s.deleteImage},onSuccess:async()=>{await d.invalidateQueries({queryKey:x.images.listAll(),exact:!1}),i("Image deleted"),u({to:E,search:{page:1}})},onError:s=>{i(C(s,"Failed to delete image"))}}),N=v({mutationFn:async()=>{const s=await K("heroBanner",o.url);if(s.type==="error")throw s},onSuccess:async()=>{await d.invalidateQueries({queryKey:x.ui.heroBanner(),exact:!0}),i("Hero banner updated")},onError:s=>{i(C(s,"Failed to update hero banner"))}}),k=async()=>{!h||f.isPending||await n("Delete this image? It is not referenced by any notes.")&&f.mutate()};return e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row",children:[e.jsx("div",{className:"w-full lg:w-[400px] lg:flex-shrink-0",children:e.jsxs(g,{flush:!0,children:[e.jsx("div",{className:T,style:{height:j},children:e.jsx(V,{className:re,src:o.url,alt:`Image ${o.id}`})}),e.jsxs("div",{className:"flex flex-col gap-4 border-t border-border-subtle p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:14,className:"text-fg-tertiary"}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:y})]}),e.jsx(r,{as:"p",variant:"meta",tone:"tertiary",children:h?"Delete is available because no notes reference this image":"Remove this image from notes before deleting it"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{content:h?"Delete this image":"Cannot delete while referenced by notes",side:"bottom",children:e.jsxs(w,{variant:"soft-danger",size:"sm",className:"flex-1",disabled:!h,isLoading:f.isPending,onClick:k,children:[e.jsx(Y,{size:16}),"Delete"]})}),e.jsxs(w,{variant:"primary",size:"sm",className:"flex-1",isLoading:N.isPending,onClick:()=>N.mutate(),children:[e.jsx(ee,{size:16}),"Set hero banner"]})]})]})]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs(g,{children:[e.jsxs("div",{className:M,children:[e.jsxs("div",{className:S,children:[e.jsx(r,{as:"h2",variant:"subheading",weight:"medium",tracking:"tight",children:"Referenced Notes"}),e.jsx(r,{as:"p",variant:"meta",tone:"secondary",children:"Notes currently using this image"})]}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:y})]}),c>0?e.jsx("ul",{className:"flex flex-col",children:m.map(s=>e.jsx("li",{children:e.jsx(se,{...s})},s.id))}):e.jsxs("div",{className:"flex items-start gap-3 py-1",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[10px] bg-muted/25 text-fg-disabled",children:e.jsx(J,{size:18})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(r,{as:"p",variant:"body",weight:"medium",tone:"secondary",children:"No notes reference this image"}),e.jsx(r,{as:"p",variant:"meta",tone:"secondary",children:"This image can be deleted or reused in another note"})]})]})]})})]})},pe=()=>{const{id:a}=I.useParams();return e.jsxs(e.Fragment,{children:[e.jsx(Z,{children:e.jsx("title",{children:"Image Detail | Ocean Brain"})}),e.jsxs(p,{to:E,search:{page:1},className:te,children:[e.jsx(q,{size:16}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:"Back to Images"})]}),e.jsx(r,{as:"h1",variant:"heading",weight:"bold",tracking:"tighter",className:"sr-only",children:"Image Detail"}),e.jsx(B,{fallback:e.jsx(ie,{}),errorTitle:"Failed to load image detail",errorDescription:"Retry loading the image preview and its referenced notes",resetKeys:[a],children:e.jsx(le,{id:a})})]})};export{pe as default};
@@ -1 +1 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{aR as r,k as Q,u as B,ah as p,P as E,T as t,aS as G,B as M,n as w,w as J,I as K,o as O,r as T,m as U}from"./index-BFfQKAUY.js";import{a as h}from"./graph-vendor-CUxe67Lr.js";import{S as x}from"./SurfaceCard-CfL1jD-O.js";import"./note-core-Z6kqulGB.js";const D=async()=>{const{data:s}=await r.get("/api/mcp-admin/status");return s},z=async s=>{const{data:n}=await r.post("/api/mcp-admin/enabled",{enabled:s});return n},V=async()=>{const{data:s}=await r.post("/api/mcp-admin/token/rotate");return s},H=async()=>{const{data:s}=await r.post("/api/mcp-admin/token/revoke");return s},o=["mcp-admin","status"],W=s=>JSON.stringify({mcpServers:{"ocean-brain":{command:"npx",args:["-y","ocean-brain","mcp","--server",s,"--token-file","/path/to/token.txt"]}}},null,2),X=s=>JSON.stringify({mcpServers:{"ocean-brain":{command:"npx",args:["-y","ocean-brain","mcp","--server",s,"--token","your-token-here"]}}},null,2),se=()=>{const s=U(),n=Q(),[c,S]=h.useState(()=>window.location.origin),[v,g]=h.useState(""),[k,P]=h.useState("token-file"),{data:y,isLoading:A}=B({queryKey:o,queryFn:D}),b=p({mutationFn:z,onSuccess:a=>{n.setQueryData(o,a),s(a.enabled?"MCP access enabled.":"MCP access disabled.")}}),j=p({mutationFn:V,onSuccess:async({token:a})=>{g(a),s("A new MCP token has been issued."),await n.invalidateQueries({queryKey:o})}}),f=p({mutationFn:H,onSuccess:a=>{g(""),n.setQueryData(o,a),s("The active MCP token has been revoked.")}}),l=y?.enabled??!1,d=y?.hasActiveToken??!1,I=!A&&!b.isPending,i="space-y-1",N="space-y-4.5",F="inline-flex items-center gap-3 rounded-[14px] border border-border-subtle bg-muted px-3 py-2",L="rounded-full border border-border-subtle bg-hover-subtle px-2.5 py-1",R="space-y-3 rounded-[16px] border border-border-subtle bg-surface px-4 py-3",q="overflow-x-auto rounded-[14px] border border-border-subtle bg-surface px-4 py-3 text-xs text-fg-secondary",u={variant:"subheading",weight:"medium",tracking:"tight"},C="font-medium text-fg-tertiary",m=k==="token-file"?{title:"Token file",description:"Recommended. Keeps the token out of config.",snippet:W(c)}:{title:"Inline token",description:"Useful for quick local testing.",snippet:X(c)};return e.jsx(E,{title:"MCP",variant:"default",description:"Manage MCP access, tokens, and connection details",children:e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsx(x,{tone:"elevated",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"h2",...u,children:"MCP Access"}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",children:"Allow or block MCP requests at the server level."})]}),e.jsxs("div",{className:F,children:[e.jsx(t,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:l?"Enabled":"Disabled"}),e.jsx(G,{"aria-label":"Allow MCP access",checked:l,disabled:!I,onCheckedChange:()=>{b.mutate(!l)}})]})]})}),e.jsx(x,{tone:"elevated",children:e.jsxs("div",{className:N,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"h2",...u,children:"Token Management"}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",className:"max-w-[64ch]",children:"Ocean Brain supports one active MCP token at a time. Rotating immediately invalidates the previous one."})]}),e.jsx(t,{as:"span",variant:"meta",weight:"medium",tone:d?"secondary":"tertiary",className:L,children:d?"1 active token":"No active token"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(M,{onClick:()=>j.mutate(void 0),isLoading:j.isPending,children:"Rotate token"}),e.jsx(M,{variant:"soft-danger",onClick:()=>f.mutate(),isLoading:f.isPending,disabled:!d,children:"Revoke token"})]}),v&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(w,{htmlFor:"issued-mcp-token",className:C,children:"Issued token"}),e.jsx(J,{id:"issued-mcp-token",rows:3,readOnly:!0,value:v})]})]})}),e.jsx(x,{tone:"elevated",children:e.jsxs("div",{className:N,children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"h2",...u,children:"Connection Guide"}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",children:"Connect your MCP client with either a token file or an inline token."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"mcp-server-url",className:C,children:"Server URL"}),e.jsx(K,{id:"mcp-server-url",value:c,onChange:a=>S(a.target.value)})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(O,{type:"single",variant:"pills",size:"sm",value:k,onValueChange:a=>{(a==="token-file"||a==="inline-token")&&P(a)},children:[e.jsx(T,{value:"token-file",children:"Token file"}),e.jsx(T,{value:"inline-token",children:"Inline token"})]}),e.jsxs("div",{className:R,children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"p",variant:"meta",weight:"semibold",children:m.title}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",children:m.description})]}),e.jsx("pre",{className:q,children:m.snippet})]})]})]})})]})})};export{se as default};
1
+ import{j as e}from"./note-vendor-i1M2FSI2.js";import{aR as r,k as Q,u as B,ah as p,P as E,T as t,aS as G,B as M,n as w,w as J,I as K,o as O,r as T,m as U}from"./index-jIfkRdY_.js";import{a as h}from"./graph-vendor-CUxe67Lr.js";import{S as x}from"./SurfaceCard-CkAVMLPs.js";import"./note-core-Z6kqulGB.js";const D=async()=>{const{data:s}=await r.get("/api/mcp-admin/status");return s},z=async s=>{const{data:n}=await r.post("/api/mcp-admin/enabled",{enabled:s});return n},V=async()=>{const{data:s}=await r.post("/api/mcp-admin/token/rotate");return s},H=async()=>{const{data:s}=await r.post("/api/mcp-admin/token/revoke");return s},o=["mcp-admin","status"],W=s=>JSON.stringify({mcpServers:{"ocean-brain":{command:"npx",args:["-y","ocean-brain","mcp","--server",s,"--token-file","/path/to/token.txt"]}}},null,2),X=s=>JSON.stringify({mcpServers:{"ocean-brain":{command:"npx",args:["-y","ocean-brain","mcp","--server",s,"--token","your-token-here"]}}},null,2),se=()=>{const s=U(),n=Q(),[c,S]=h.useState(()=>window.location.origin),[v,g]=h.useState(""),[k,P]=h.useState("token-file"),{data:y,isLoading:A}=B({queryKey:o,queryFn:D}),b=p({mutationFn:z,onSuccess:a=>{n.setQueryData(o,a),s(a.enabled?"MCP access enabled.":"MCP access disabled.")}}),j=p({mutationFn:V,onSuccess:async({token:a})=>{g(a),s("A new MCP token has been issued."),await n.invalidateQueries({queryKey:o})}}),f=p({mutationFn:H,onSuccess:a=>{g(""),n.setQueryData(o,a),s("The active MCP token has been revoked.")}}),l=y?.enabled??!1,d=y?.hasActiveToken??!1,I=!A&&!b.isPending,i="space-y-1",N="space-y-4.5",F="inline-flex items-center gap-3 rounded-[14px] border border-border-subtle bg-muted px-3 py-2",L="rounded-full border border-border-subtle bg-hover-subtle px-2.5 py-1",R="space-y-3 rounded-[16px] border border-border-subtle bg-surface px-4 py-3",q="overflow-x-auto rounded-[14px] border border-border-subtle bg-surface px-4 py-3 text-xs text-fg-secondary",u={variant:"subheading",weight:"medium",tracking:"tight"},C="font-medium text-fg-tertiary",m=k==="token-file"?{title:"Token file",description:"Recommended. Keeps the token out of config.",snippet:W(c)}:{title:"Inline token",description:"Useful for quick local testing.",snippet:X(c)};return e.jsx(E,{title:"MCP",variant:"default",description:"Manage MCP access, tokens, and connection details",children:e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsx(x,{tone:"elevated",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"h2",...u,children:"MCP Access"}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",children:"Allow or block MCP requests at the server level."})]}),e.jsxs("div",{className:F,children:[e.jsx(t,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:l?"Enabled":"Disabled"}),e.jsx(G,{"aria-label":"Allow MCP access",checked:l,disabled:!I,onCheckedChange:()=>{b.mutate(!l)}})]})]})}),e.jsx(x,{tone:"elevated",children:e.jsxs("div",{className:N,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"h2",...u,children:"Token Management"}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",className:"max-w-[64ch]",children:"Ocean Brain supports one active MCP token at a time. Rotating immediately invalidates the previous one."})]}),e.jsx(t,{as:"span",variant:"meta",weight:"medium",tone:d?"secondary":"tertiary",className:L,children:d?"1 active token":"No active token"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(M,{onClick:()=>j.mutate(void 0),isLoading:j.isPending,children:"Rotate token"}),e.jsx(M,{variant:"soft-danger",onClick:()=>f.mutate(),isLoading:f.isPending,disabled:!d,children:"Revoke token"})]}),v&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(w,{htmlFor:"issued-mcp-token",className:C,children:"Issued token"}),e.jsx(J,{id:"issued-mcp-token",rows:3,readOnly:!0,value:v})]})]})}),e.jsx(x,{tone:"elevated",children:e.jsxs("div",{className:N,children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"h2",...u,children:"Connection Guide"}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",children:"Connect your MCP client with either a token file or an inline token."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"mcp-server-url",className:C,children:"Server URL"}),e.jsx(K,{id:"mcp-server-url",value:c,onChange:a=>S(a.target.value)})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(O,{type:"single",variant:"pills",size:"sm",value:k,onValueChange:a=>{(a==="token-file"||a==="inline-token")&&P(a)},children:[e.jsx(T,{value:"token-file",children:"Token file"}),e.jsx(T,{value:"inline-token",children:"Inline token"})]}),e.jsxs("div",{className:R,children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"p",variant:"meta",weight:"semibold",children:m.title}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",children:m.description})]}),e.jsx("pre",{className:q,children:m.snippet})]})]})]})})]})})};export{se as default};
@@ -1,4 +1,4 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{p as J,h as P,k as V,q as v,b4 as W,u as ee,ah as M,P as ae,T as s,am as te,b5 as j,b6 as N,B as C,a8 as se,M as m,n as b,I as w,x as le,ac as ne,a1 as re,i as $,j as ce,aP as ie,m as oe}from"./index-BFfQKAUY.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{S as D}from"./SurfaceCard-CfL1jD-O.js";import{n as de}from"./Plus.es-Yq7J1Ur4.js";import"./note-core-Z6kqulGB.js";const me=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,160H48l80-80Z",opacity:"0.2"}),a.createElement("path",{d:"M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z"}))]]),k=a.forwardRef((l,c)=>a.createElement(J,{ref:c,...l,weights:me}));k.displayName="CaretUpIcon";const he=k,O=["id","name","template","replacement","createdAt","updatedAt"],ue=new Set(O),pe=`query FetchPlaceholders(
1
+ import{j as e}from"./note-vendor-i1M2FSI2.js";import{p as J,h as P,k as V,q as v,b4 as W,u as ee,ah as M,P as ae,T as s,am as te,b5 as j,b6 as N,B as C,a8 as se,M as m,n as b,I as w,x as le,ac as ne,a1 as re,i as $,j as ce,aP as ie,m as oe}from"./index-jIfkRdY_.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{S as D}from"./SurfaceCard-CkAVMLPs.js";import{n as de}from"./Plus.es-Dc_js8AC.js";import"./note-core-Z6kqulGB.js";const me=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,160H48l80-80Z",opacity:"0.2"}),a.createElement("path",{d:"M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z"}))]]),k=a.forwardRef((l,c)=>a.createElement(J,{ref:c,...l,weights:me}));k.displayName="CaretUpIcon";const he=k,O=["id","name","template","replacement","createdAt","updatedAt"],ue=new Set(O),pe=`query FetchPlaceholders(
2
2
  $searchFilter: SearchFilterInput,
3
3
  $pagination: PaginationInput
4
4
  ) {
@@ -1 +1 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{k as oe,u as de,H as ce,q as x,ah as M,b1 as ue,b2 as me,b3 as pe,P as he,T as s,B as o,M as d,I as v,S as xe,e as be,x as q,m as ve,j as ye,aI as ge}from"./index-BFfQKAUY.js";import{a as p}from"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.js";const fe=ye(ge),W=[{value:"text",label:"Text",description:"Short status or label values."},{value:"url",label:"URL",description:"External sources, issues, docs, or references."},{value:"number",label:"Number",description:"Priority, score, or count values."},{value:"date",label:"Date",description:"Due dates and milestones."},{value:"boolean",label:"Boolean",description:"True or false flags."},{value:"select",label:"Select",description:"Choose one option from a controlled list."}],je=l=>!l.id&&!l.label.trim()&&!l.value.trim(),Ne=l=>(l.value.trim()||l.label.trim()).toLowerCase().replace(/\s+/g,"-"),Ce=l=>/^[a-z0-9][a-z0-9_-]*$/.test(l),X=l=>l.filter(r=>r.id||r.label.trim()).map((r,F)=>({...r.id?{id:r.id}:{},label:r.label.trim(),value:r.value.trim()||r.label.trim(),color:r.color??null,order:r.order??F}));function Ee(){const l=ve(),r=oe(),F=fe.useSearch(),Z=Number(F.page??1),R=50,V=Math.max(0,Z-1)*R,[k,I]=p.useState(""),[Q,A]=p.useState(""),[y,H]=p.useState("text"),[D,j]=p.useState([{label:"",value:""}]),[u,N]=p.useState(null),[i,$]=p.useState(null),[O,L]=p.useState(""),[E,g]=p.useState([{label:"",value:""}]),[ee,C]=p.useState(!1),S=()=>{I(""),A(""),H("text"),j([{label:"",value:""}])},ae=a=>{$(a),L(a.name),g(a.options.length>0?a.options.map(t=>({id:t.id,label:t.label,value:t.value,color:t.color,order:t.order})):[{label:"",value:""}])},T=()=>{$(null),L(""),g([{label:"",value:""}])},_=de({queryKey:x.notes.propertyKeys({limit:R,offset:V}),queryFn:async()=>{const a=await ce({limit:R,offset:V});if(a.type==="error")throw a;return a.notePropertyKeys}}),w=M({mutationFn:async()=>ue({key:k,name:Q||k,valueType:y,...y==="select"?{options:D.map((a,t)=>({label:a.label.trim(),value:a.value.trim()||a.label.trim(),order:t})).filter(a=>a.label)}:{}}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to create property.");return}S(),C(!1),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),l("Property created.")},onError:()=>{l("Failed to create property.")}}),h=M({mutationFn:async()=>{if(!i)throw new Error("Property to edit is missing.");return me({key:i.key,name:O||i.key,...i.valueType==="select"?{options:X(E)}:{}})},onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to update property.");return}T(),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),l("Property updated.")},onError:()=>{l("Failed to update property.")}}),f=M({mutationFn:async({propertyKey:a,confirmImpact:t})=>pe({key:a.key,confirmImpact:t}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to delete property.");return}r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),N(null),l(a.deleteNotePropertyKey.affectedNoteCount>0?`Property deleted from ${a.deleteNotePropertyKey.affectedNoteCount} note(s).`:"Property deleted.")},onError:()=>{l("Failed to delete property.")}}),P=_.data?.keys??[],se=y!=="select"||D.some(a=>a.label.trim()),z=i?.valueType==="select"?E.filter(a=>!je(a)):[],B=z.map(Ne),K=B.find((a,t)=>B.indexOf(a)!==t),U=B.find(a=>!Ce(a)),J=z.some(a=>!!a.id&&!a.label.trim()),Y=z.some(a=>!a.id&&!a.label.trim()),te=!i||i.valueType!=="select"||z.length>0&&!J&&!Y&&!K&&!U,le=!!i&&O.trim()!==i?.name,re=i?.valueType==="select"&&JSON.stringify(X(E))!==JSON.stringify(i.options.map(a=>({id:a.id,label:a.label,value:a.value,color:a.color??null,order:a.order}))),ie=le||!!re,G=J?"Existing option labels cannot be empty.":Y?"New options need a label.":K?`Option value “${K}” is duplicated.`:U?"Option values must use letters, numbers, dashes, or underscores.":"",ne=()=>{u&&f.mutate({propertyKey:u,confirmImpact:u.noteCount>0})};return e.jsxs(he,{title:"Properties",description:"Define shared note fields before using them in notes and future views.",headerRight:e.jsx(o,{type:"button",size:"md",variant:"primary",className:"w-full sm:w-auto",onClick:()=>C(!0),children:"New property"}),children:[e.jsxs("section",{className:"flex flex-col gap-3","aria-labelledby":"shared-properties-heading",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(s,{id:"shared-properties-heading",as:"h2",variant:"label",weight:"medium",className:"text-fg-tertiary",children:"Shared fields"}),!_.isLoading&&P.length>0&&e.jsxs(s,{as:"span",variant:"meta",tone:"tertiary",children:[P.length," field",P.length===1?"":"s"]})]}),_.isLoading?e.jsx(s,{as:"p",variant:"body",tone:"tertiary",className:"surface-base px-4 py-3.5",children:"Loading properties..."}):P.length===0?e.jsxs("div",{className:"surface-base border-dashed p-6 text-center",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"No shared properties yet."}),e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create one here, then attach it from the note screen."})]}):e.jsx("div",{className:"flex flex-col gap-3",children:P.map(a=>e.jsxs("article",{className:"surface-base grid gap-3 px-4 py-3.5 md:grid-cols-[minmax(0,1fr)_120px_120px_auto] md:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"h3",variant:"body",weight:"semibold",className:"truncate",children:a.name}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"font-mono",children:a.key}),a.options.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.options.slice(0,6).map(t=>e.jsx("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-secondary",children:t.label},t.id)),a.options.length>6&&e.jsxs("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-tertiary",children:["+",a.options.length-6]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Type"}),e.jsx(s,{as:"span",variant:"label",tone:"secondary",className:"capitalize",children:a.valueType})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Used in"}),e.jsxs(s,{as:"span",variant:"label",tone:"tertiary",children:[a.noteCount," note",a.noteCount===1?"":"s"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-self-start md:justify-self-end",children:[e.jsx(o,{type:"button",size:"sm",variant:"subtle",disabled:h.isPending||f.isPending,onClick:()=>ae(a),children:"Edit"}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",disabled:f.isPending||h.isPending,onClick:()=>N(a),children:"Delete"})]})]},a.key))})]}),e.jsxs(d,{isOpen:ee,onClose:()=>{w.isPending||(C(!1),S())},variant:"form",children:[e.jsx(d.Header,{title:"New property",onClose:()=>{C(!1),S()}}),e.jsx(d.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create a shared field that notes can use for values and future views."}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Key"}),e.jsx(v,{size:"md",placeholder:"status",value:k,onChange:a=>I(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Name"}),e.jsx(v,{size:"md",placeholder:"Status",value:Q,onChange:a=>A(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Type"}),e.jsx(xe,{value:y,onValueChange:a=>H(a),children:W.map(a=>e.jsx(be,{value:a.value,children:a.label},a.value))})]}),y==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>j(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:D.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:"value",value:a.value,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>j(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},t))})]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",children:W.find(a=>a.value===y)?.description})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:w.isPending,onClick:()=>{C(!1),S()},children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!k.trim()||!se||w.isPending,isLoading:w.isPending,onClick:()=>w.mutate(),children:"Create property"})]})})]}),e.jsxs(d,{isOpen:!!i,onClose:()=>{h.isPending||T()},variant:"form",children:[e.jsx(d.Header,{title:"Edit property",onClose:()=>{h.isPending||T()}}),e.jsx(d.Body,{children:i&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Rename the display label or add select options. Key, type, and existing option values stay fixed so notes and views remain stable."}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Key"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"font-mono",children:i.key})]}),e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Type"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"capitalize",children:i.valueType})]})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Display name"}),e.jsx(v,{size:"md",placeholder:"Workflow state",value:O,onChange:a=>L(a.target.value)})]}),i.valueType==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5",children:"Existing option values are locked. Removing existing options needs an impact-aware delete flow."})]}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>g(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:E.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:a.id?"Locked value":"value",value:a.value,disabled:!!a.id,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),a.id?e.jsx(s,{as:"span",variant:"meta",tone:"tertiary",className:"flex h-8 items-center px-3",children:"Locked"}):e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>g(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},a.id??`new-${t}`))}),G&&e.jsx(s,{as:"p",variant:"micro",tone:"error",className:"mt-2",children:G})]})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:h.isPending,onClick:T,children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!O.trim()||!ie||!te||h.isPending,isLoading:h.isPending,onClick:()=>h.mutate(),children:"Save changes"})]})})]}),e.jsxs(d,{isOpen:!!u,onClose:()=>{f.isPending||N(null)},variant:"confirm",children:[e.jsx(d.Header,{title:"Delete property",onClose:()=>N(null)}),e.jsx(d.Body,{children:u&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(s,{as:"p",variant:"body",weight:"medium",children:["Delete “",u.name,"”?"]}),u.noteCount>0?e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle p-3",children:[e.jsxs(s,{as:"p",variant:"label",tone:"secondary",children:["This property is used by ",u.noteCount," note",u.noteCount===1?"":"s","."]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-1 leading-5",children:"Deleting it removes this value from those notes. Future views using this property will need configuration."})]}):e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"This property is not used by any note yet."})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:f.isPending,onClick:()=>N(null),children:"Cancel"}),e.jsx(o,{type:"button",variant:"danger",size:"sm",isLoading:f.isPending,onClick:ne,children:"Delete"})]})})]})]})}export{Ee as default};
1
+ import{j as e}from"./note-vendor-i1M2FSI2.js";import{k as oe,u as de,H as ce,q as x,ah as M,b1 as ue,b2 as me,b3 as pe,P as he,T as s,B as o,M as d,I as v,S as xe,e as be,x as q,m as ve,j as ye,aI as ge}from"./index-jIfkRdY_.js";import{a as p}from"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.js";const fe=ye(ge),W=[{value:"text",label:"Text",description:"Short status or label values."},{value:"url",label:"URL",description:"External sources, issues, docs, or references."},{value:"number",label:"Number",description:"Priority, score, or count values."},{value:"date",label:"Date",description:"Due dates and milestones."},{value:"boolean",label:"Boolean",description:"True or false flags."},{value:"select",label:"Select",description:"Choose one option from a controlled list."}],je=l=>!l.id&&!l.label.trim()&&!l.value.trim(),Ne=l=>(l.value.trim()||l.label.trim()).toLowerCase().replace(/\s+/g,"-"),Ce=l=>/^[a-z0-9][a-z0-9_-]*$/.test(l),X=l=>l.filter(r=>r.id||r.label.trim()).map((r,F)=>({...r.id?{id:r.id}:{},label:r.label.trim(),value:r.value.trim()||r.label.trim(),color:r.color??null,order:r.order??F}));function Ee(){const l=ve(),r=oe(),F=fe.useSearch(),Z=Number(F.page??1),R=50,V=Math.max(0,Z-1)*R,[k,I]=p.useState(""),[Q,A]=p.useState(""),[y,H]=p.useState("text"),[D,j]=p.useState([{label:"",value:""}]),[u,N]=p.useState(null),[i,$]=p.useState(null),[O,L]=p.useState(""),[E,g]=p.useState([{label:"",value:""}]),[ee,C]=p.useState(!1),S=()=>{I(""),A(""),H("text"),j([{label:"",value:""}])},ae=a=>{$(a),L(a.name),g(a.options.length>0?a.options.map(t=>({id:t.id,label:t.label,value:t.value,color:t.color,order:t.order})):[{label:"",value:""}])},T=()=>{$(null),L(""),g([{label:"",value:""}])},_=de({queryKey:x.notes.propertyKeys({limit:R,offset:V}),queryFn:async()=>{const a=await ce({limit:R,offset:V});if(a.type==="error")throw a;return a.notePropertyKeys}}),w=M({mutationFn:async()=>ue({key:k,name:Q||k,valueType:y,...y==="select"?{options:D.map((a,t)=>({label:a.label.trim(),value:a.value.trim()||a.label.trim(),order:t})).filter(a=>a.label)}:{}}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to create property.");return}S(),C(!1),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),l("Property created.")},onError:()=>{l("Failed to create property.")}}),h=M({mutationFn:async()=>{if(!i)throw new Error("Property to edit is missing.");return me({key:i.key,name:O||i.key,...i.valueType==="select"?{options:X(E)}:{}})},onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to update property.");return}T(),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),l("Property updated.")},onError:()=>{l("Failed to update property.")}}),f=M({mutationFn:async({propertyKey:a,confirmImpact:t})=>pe({key:a.key,confirmImpact:t}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to delete property.");return}r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),N(null),l(a.deleteNotePropertyKey.affectedNoteCount>0?`Property deleted from ${a.deleteNotePropertyKey.affectedNoteCount} note(s).`:"Property deleted.")},onError:()=>{l("Failed to delete property.")}}),P=_.data?.keys??[],se=y!=="select"||D.some(a=>a.label.trim()),z=i?.valueType==="select"?E.filter(a=>!je(a)):[],B=z.map(Ne),K=B.find((a,t)=>B.indexOf(a)!==t),U=B.find(a=>!Ce(a)),J=z.some(a=>!!a.id&&!a.label.trim()),Y=z.some(a=>!a.id&&!a.label.trim()),te=!i||i.valueType!=="select"||z.length>0&&!J&&!Y&&!K&&!U,le=!!i&&O.trim()!==i?.name,re=i?.valueType==="select"&&JSON.stringify(X(E))!==JSON.stringify(i.options.map(a=>({id:a.id,label:a.label,value:a.value,color:a.color??null,order:a.order}))),ie=le||!!re,G=J?"Existing option labels cannot be empty.":Y?"New options need a label.":K?`Option value “${K}” is duplicated.`:U?"Option values must use letters, numbers, dashes, or underscores.":"",ne=()=>{u&&f.mutate({propertyKey:u,confirmImpact:u.noteCount>0})};return e.jsxs(he,{title:"Properties",description:"Define shared note fields before using them in notes and future views.",headerRight:e.jsx(o,{type:"button",size:"md",variant:"primary",className:"w-full sm:w-auto",onClick:()=>C(!0),children:"New property"}),children:[e.jsxs("section",{className:"flex flex-col gap-3","aria-labelledby":"shared-properties-heading",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(s,{id:"shared-properties-heading",as:"h2",variant:"label",weight:"medium",className:"text-fg-tertiary",children:"Shared fields"}),!_.isLoading&&P.length>0&&e.jsxs(s,{as:"span",variant:"meta",tone:"tertiary",children:[P.length," field",P.length===1?"":"s"]})]}),_.isLoading?e.jsx(s,{as:"p",variant:"body",tone:"tertiary",className:"surface-base px-4 py-3.5",children:"Loading properties..."}):P.length===0?e.jsxs("div",{className:"surface-base border-dashed p-6 text-center",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"No shared properties yet."}),e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create one here, then attach it from the note screen."})]}):e.jsx("div",{className:"flex flex-col gap-3",children:P.map(a=>e.jsxs("article",{className:"surface-base grid gap-3 px-4 py-3.5 md:grid-cols-[minmax(0,1fr)_120px_120px_auto] md:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"h3",variant:"body",weight:"semibold",className:"truncate",children:a.name}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"font-mono",children:a.key}),a.options.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.options.slice(0,6).map(t=>e.jsx("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-secondary",children:t.label},t.id)),a.options.length>6&&e.jsxs("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-tertiary",children:["+",a.options.length-6]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Type"}),e.jsx(s,{as:"span",variant:"label",tone:"secondary",className:"capitalize",children:a.valueType})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Used in"}),e.jsxs(s,{as:"span",variant:"label",tone:"tertiary",children:[a.noteCount," note",a.noteCount===1?"":"s"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-self-start md:justify-self-end",children:[e.jsx(o,{type:"button",size:"sm",variant:"subtle",disabled:h.isPending||f.isPending,onClick:()=>ae(a),children:"Edit"}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",disabled:f.isPending||h.isPending,onClick:()=>N(a),children:"Delete"})]})]},a.key))})]}),e.jsxs(d,{isOpen:ee,onClose:()=>{w.isPending||(C(!1),S())},variant:"form",children:[e.jsx(d.Header,{title:"New property",onClose:()=>{C(!1),S()}}),e.jsx(d.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create a shared field that notes can use for values and future views."}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Key"}),e.jsx(v,{size:"md",placeholder:"status",value:k,onChange:a=>I(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Name"}),e.jsx(v,{size:"md",placeholder:"Status",value:Q,onChange:a=>A(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Type"}),e.jsx(xe,{value:y,onValueChange:a=>H(a),children:W.map(a=>e.jsx(be,{value:a.value,children:a.label},a.value))})]}),y==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>j(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:D.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:"value",value:a.value,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>j(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},t))})]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",children:W.find(a=>a.value===y)?.description})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:w.isPending,onClick:()=>{C(!1),S()},children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!k.trim()||!se||w.isPending,isLoading:w.isPending,onClick:()=>w.mutate(),children:"Create property"})]})})]}),e.jsxs(d,{isOpen:!!i,onClose:()=>{h.isPending||T()},variant:"form",children:[e.jsx(d.Header,{title:"Edit property",onClose:()=>{h.isPending||T()}}),e.jsx(d.Body,{children:i&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Rename the display label or add select options. Key, type, and existing option values stay fixed so notes and views remain stable."}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Key"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"font-mono",children:i.key})]}),e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Type"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"capitalize",children:i.valueType})]})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Display name"}),e.jsx(v,{size:"md",placeholder:"Workflow state",value:O,onChange:a=>L(a.target.value)})]}),i.valueType==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5",children:"Existing option values are locked. Removing existing options needs an impact-aware delete flow."})]}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>g(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:E.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:a.id?"Locked value":"value",value:a.value,disabled:!!a.id,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),a.id?e.jsx(s,{as:"span",variant:"meta",tone:"tertiary",className:"flex h-8 items-center px-3",children:"Locked"}):e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>g(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},a.id??`new-${t}`))}),G&&e.jsx(s,{as:"p",variant:"micro",tone:"error",className:"mt-2",children:G})]})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:h.isPending,onClick:T,children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!O.trim()||!ie||!te||h.isPending,isLoading:h.isPending,onClick:()=>h.mutate(),children:"Save changes"})]})})]}),e.jsxs(d,{isOpen:!!u,onClose:()=>{f.isPending||N(null)},variant:"confirm",children:[e.jsx(d.Header,{title:"Delete property",onClose:()=>N(null)}),e.jsx(d.Body,{children:u&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(s,{as:"p",variant:"body",weight:"medium",children:["Delete “",u.name,"”?"]}),u.noteCount>0?e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle p-3",children:[e.jsxs(s,{as:"p",variant:"label",tone:"secondary",children:["This property is used by ",u.noteCount," note",u.noteCount===1?"":"s","."]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-1 leading-5",children:"Deleting it removes this value from those notes. Future views using this property will need configuration."})]}):e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"This property is not used by any note yet."})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:f.isPending,onClick:()=>N(null),children:"Cancel"}),e.jsx(o,{type:"button",variant:"danger",size:"sm",isLoading:f.isPending,onClick:ne,children:"Delete"})]})})]})]})}export{Ee as default};
@@ -1 +1 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{a0 as M,j as Q,aw as F,k as L,y as _,a6 as I,aT as K,q as i,ah as E,aU as B,N as O,aV as W,P as N,J as H,T as d,ax as U,B as j,a1 as V,aW as Y,i as l,m as $,d as z,al as G,u as J,aX as X,M as y}from"./index-BFfQKAUY.js";import{a as k}from"./graph-vendor-CUxe67Lr.js";import{S as C}from"./SurfaceCard-CfL1jD-O.js";import"./note-core-Z6kqulGB.js";const m=25,v=Q(F),S=30,R=`Deleted notes stay here for ${S} days before permanent removal`,g={title:"Permanently delete note?",description:"This note is referenced by the notes below. If you permanently delete it, those links will stay broken. Other notes will not be edited automatically.",confirmLabel:"Delete now",confirmVariant:"danger"},P=a=>z(a).format("YYYY-MM-DD HH:mm"),Z=({note:a,onClose:o})=>{const s=a?.id??"",c=a?.title||"Untitled note",r=J({queryKey:i.notes.trashDetail(s),enabled:!!a,queryFn:async()=>{const h=await X(s);if(h.type==="error")throw h;if(!h.trashedNote)throw new Error("Trashed note not found");return h.trashedNote}}),f=r.data?.contentAsMarkdown.trim()??"";return e.jsxs(y,{isOpen:!!a,onClose:o,variant:"inspect",children:[e.jsx(y.Header,{title:c,onClose:o}),e.jsx(y.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[a&&e.jsxs(d,{as:"p",variant:"meta",tone:"secondary",children:["Deleted ",P(a.deletedAt)]}),r.isLoading&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",children:"Loading deleted note content..."}),r.isError&&e.jsx(d,{as:"p",variant:"meta",tone:"error",children:"Failed to load deleted note content."}),!r.isLoading&&!r.isError&&f&&e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:f}),!r.isLoading&&!r.isError&&!f&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this deleted note."})]})}),e.jsx(y.Footer,{children:e.jsx(j,{variant:"ghost",size:"sm",onClick:o,children:"Close"})})]})},ee=()=>e.jsx(N,{title:"Trash",variant:"default",heading:e.jsx(l,{width:118,height:24,className:"rounded-full"}),description:e.jsx(l,{width:352,height:16,className:"rounded-full"}),children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:3},(a,o)=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx(l,{width:"40%",height:18,className:"rounded-full"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:168,height:14,className:"rounded-full"}),e.jsx(l,{width:176,height:14,className:"rounded-full"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:56,height:24,className:"rounded-full"}),e.jsx(l,{width:72,height:24,className:"rounded-full"})]})]}),e.jsx(l,{width:92,height:32,className:"rounded-[12px]"})]})},o))})}),te=()=>{const{page:a}=v.useSearch(),o=v.useNavigate(),s=L(),c=$(),r=_(),[f,h]=k.useState(null),[x,b]=k.useState(null),{data:u}=I({queryKey:i.notes.trash({limit:m,offset:(a-1)*m}),queryFn:async()=>{const t=await K({limit:m,offset:(a-1)*m});if(t.type==="error")throw t;return t.trashedNotes}}),w=E({mutationFn:B,onSuccess:async t=>{if(t.type==="error")throw t;await Promise.all([s.invalidateQueries({queryKey:i.notes.all(),exact:!1}),s.invalidateQueries({queryKey:i.tags.all(),exact:!1}),s.invalidateQueries({queryKey:i.reminders.all(),exact:!1}),s.invalidateQueries({queryKey:i.images.all(),exact:!1}),s.invalidateQueries({queryKey:i.calendar.all(),exact:!1})]),c("The note has been restored."),o({to:O,params:{id:t.restoreTrashedNote.id}})},onError:()=>{c("Failed to restore the note.")}}),p=E({mutationFn:W,onSuccess:async t=>{if(t.type==="error")throw t;await s.invalidateQueries({queryKey:i.notes.trashAll(),exact:!1}),c("The note has been permanently deleted.")},onError:()=>{c("Failed to permanently delete the note.")}}),D=()=>{if(!x)return;const{id:t}=x;b(null),p.mutate(t)},q=async t=>{const n=await G(t);if(n.type==="error"){c("Failed to check linked notes before permanently deleting this note.");return}if(s.setQueryData(i.notes.backReferences(t),n.backReferences),n.backReferences.length>0){b({id:t,backReferences:n.backReferences});return}await r("Permanently delete this note? This cannot be undone.")&&p.mutate(t)},T=u.totalCount>0?`Trash (${u.totalCount})`:void 0,A=u.notes.find(t=>t.id===f)??null;return u.notes.length===0?e.jsx(N,{title:"Trash",variant:"default",heading:T,description:R,children:e.jsx(H,{title:"Trash is empty",description:`Delete a note and you can restore it here for ${S} days before permanent removal`})}):e.jsxs(N,{title:"Trash",variant:"default",heading:T,description:R,children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid gap-3",children:u.notes.map(t=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[e.jsx(d,{as:"h2",variant:"body",weight:"medium",className:"min-w-0 flex-1 break-words leading-[1.25]",children:t.title||"Untitled note"}),t.pinned&&e.jsx("span",{title:"Pinned",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center text-fg-tertiary",children:e.jsx(U,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsxs(d,{as:"div",variant:"meta",weight:"medium",tone:"secondary",children:["Deleted ",P(t.deletedAt)]})}),t.tagNames.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.tagNames.map(n=>e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"rounded-full border border-border-subtle bg-hover-subtle px-2 py-0.5",children:n},`${t.id}-${n}`))}),t.contentPreview&&e.jsx("div",{className:"mt-3 rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-3 whitespace-pre-wrap break-words",children:t.contentPreview})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(j,{variant:"subtle",size:"sm",onClick:()=>h(t.id),children:"View content"}),e.jsx(j,{variant:"subtle",size:"sm",isLoading:w.isPending&&w.variables===t.id,onClick:()=>w.mutate(t.id),children:"Restore"}),e.jsx(j,{variant:"soft-danger",size:"sm",isLoading:p.isPending&&p.variables===t.id,onClick:()=>q(t.id),children:"Delete now"})]})]})},t.id))}),u.totalCount>m&&e.jsx(V,{page:a,last:Math.ceil(u.totalCount/m),onChange:t=>{o({search:n=>({...n,page:t})})}})]}),e.jsx(Z,{note:A,onClose:()=>h(null)}),e.jsx(Y,{isOpen:!!x,title:g.title,description:g.description,references:x?.backReferences??[],confirmLabel:g.confirmLabel,confirmVariant:g.confirmVariant,onClose:()=>b(null),onConfirm:D})]})},oe=()=>{const{page:a}=v.useSearch();return e.jsx(M,{fallback:e.jsx(ee,{}),errorTitle:"Failed to load trash",errorDescription:"Retry loading deleted notes",resetKeys:[a],children:e.jsx(te,{})})};export{oe as default};
1
+ import{j as e}from"./note-vendor-i1M2FSI2.js";import{a0 as M,j as Q,aw as F,k as L,y as _,a6 as I,aT as K,q as i,ah as E,aU as B,N as O,aV as W,P as N,J as H,T as d,ax as U,B as j,a1 as V,aW as Y,i as l,m as $,d as z,al as G,u as J,aX as X,M as y}from"./index-jIfkRdY_.js";import{a as k}from"./graph-vendor-CUxe67Lr.js";import{S as C}from"./SurfaceCard-CkAVMLPs.js";import"./note-core-Z6kqulGB.js";const m=25,v=Q(F),S=30,R=`Deleted notes stay here for ${S} days before permanent removal`,g={title:"Permanently delete note?",description:"This note is referenced by the notes below. If you permanently delete it, those links will stay broken. Other notes will not be edited automatically.",confirmLabel:"Delete now",confirmVariant:"danger"},P=a=>z(a).format("YYYY-MM-DD HH:mm"),Z=({note:a,onClose:o})=>{const s=a?.id??"",c=a?.title||"Untitled note",r=J({queryKey:i.notes.trashDetail(s),enabled:!!a,queryFn:async()=>{const h=await X(s);if(h.type==="error")throw h;if(!h.trashedNote)throw new Error("Trashed note not found");return h.trashedNote}}),f=r.data?.contentAsMarkdown.trim()??"";return e.jsxs(y,{isOpen:!!a,onClose:o,variant:"inspect",children:[e.jsx(y.Header,{title:c,onClose:o}),e.jsx(y.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[a&&e.jsxs(d,{as:"p",variant:"meta",tone:"secondary",children:["Deleted ",P(a.deletedAt)]}),r.isLoading&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",children:"Loading deleted note content..."}),r.isError&&e.jsx(d,{as:"p",variant:"meta",tone:"error",children:"Failed to load deleted note content."}),!r.isLoading&&!r.isError&&f&&e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:f}),!r.isLoading&&!r.isError&&!f&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this deleted note."})]})}),e.jsx(y.Footer,{children:e.jsx(j,{variant:"ghost",size:"sm",onClick:o,children:"Close"})})]})},ee=()=>e.jsx(N,{title:"Trash",variant:"default",heading:e.jsx(l,{width:118,height:24,className:"rounded-full"}),description:e.jsx(l,{width:352,height:16,className:"rounded-full"}),children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:3},(a,o)=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx(l,{width:"40%",height:18,className:"rounded-full"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:168,height:14,className:"rounded-full"}),e.jsx(l,{width:176,height:14,className:"rounded-full"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:56,height:24,className:"rounded-full"}),e.jsx(l,{width:72,height:24,className:"rounded-full"})]})]}),e.jsx(l,{width:92,height:32,className:"rounded-[12px]"})]})},o))})}),te=()=>{const{page:a}=v.useSearch(),o=v.useNavigate(),s=L(),c=$(),r=_(),[f,h]=k.useState(null),[x,b]=k.useState(null),{data:u}=I({queryKey:i.notes.trash({limit:m,offset:(a-1)*m}),queryFn:async()=>{const t=await K({limit:m,offset:(a-1)*m});if(t.type==="error")throw t;return t.trashedNotes}}),w=E({mutationFn:B,onSuccess:async t=>{if(t.type==="error")throw t;await Promise.all([s.invalidateQueries({queryKey:i.notes.all(),exact:!1}),s.invalidateQueries({queryKey:i.tags.all(),exact:!1}),s.invalidateQueries({queryKey:i.reminders.all(),exact:!1}),s.invalidateQueries({queryKey:i.images.all(),exact:!1}),s.invalidateQueries({queryKey:i.calendar.all(),exact:!1})]),c("The note has been restored."),o({to:O,params:{id:t.restoreTrashedNote.id}})},onError:()=>{c("Failed to restore the note.")}}),p=E({mutationFn:W,onSuccess:async t=>{if(t.type==="error")throw t;await s.invalidateQueries({queryKey:i.notes.trashAll(),exact:!1}),c("The note has been permanently deleted.")},onError:()=>{c("Failed to permanently delete the note.")}}),D=()=>{if(!x)return;const{id:t}=x;b(null),p.mutate(t)},q=async t=>{const n=await G(t);if(n.type==="error"){c("Failed to check linked notes before permanently deleting this note.");return}if(s.setQueryData(i.notes.backReferences(t),n.backReferences),n.backReferences.length>0){b({id:t,backReferences:n.backReferences});return}await r("Permanently delete this note? This cannot be undone.")&&p.mutate(t)},T=u.totalCount>0?`Trash (${u.totalCount})`:void 0,A=u.notes.find(t=>t.id===f)??null;return u.notes.length===0?e.jsx(N,{title:"Trash",variant:"default",heading:T,description:R,children:e.jsx(H,{title:"Trash is empty",description:`Delete a note and you can restore it here for ${S} days before permanent removal`})}):e.jsxs(N,{title:"Trash",variant:"default",heading:T,description:R,children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid gap-3",children:u.notes.map(t=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[e.jsx(d,{as:"h2",variant:"body",weight:"medium",className:"min-w-0 flex-1 break-words leading-[1.25]",children:t.title||"Untitled note"}),t.pinned&&e.jsx("span",{title:"Pinned",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center text-fg-tertiary",children:e.jsx(U,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsxs(d,{as:"div",variant:"meta",weight:"medium",tone:"secondary",children:["Deleted ",P(t.deletedAt)]})}),t.tagNames.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.tagNames.map(n=>e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"rounded-full border border-border-subtle bg-hover-subtle px-2 py-0.5",children:n},`${t.id}-${n}`))}),t.contentPreview&&e.jsx("div",{className:"mt-3 rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-3 whitespace-pre-wrap break-words",children:t.contentPreview})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(j,{variant:"subtle",size:"sm",onClick:()=>h(t.id),children:"View content"}),e.jsx(j,{variant:"subtle",size:"sm",isLoading:w.isPending&&w.variables===t.id,onClick:()=>w.mutate(t.id),children:"Restore"}),e.jsx(j,{variant:"soft-danger",size:"sm",isLoading:p.isPending&&p.variables===t.id,onClick:()=>q(t.id),children:"Delete now"})]})]})},t.id))}),u.totalCount>m&&e.jsx(V,{page:a,last:Math.ceil(u.totalCount/m),onChange:t=>{o({search:n=>({...n,page:t})})}})]}),e.jsx(Z,{note:A,onClose:()=>h(null)}),e.jsx(Y,{isOpen:!!x,title:g.title,description:g.description,references:x?.backReferences??[],confirmLabel:g.confirmLabel,confirmVariant:g.confirmVariant,onClose:()=>b(null),onConfirm:D})]})},oe=()=>{const{page:a}=v.useSearch();return e.jsx(M,{fallback:e.jsx(ee,{}),errorTitle:"Failed to load trash",errorDescription:"Retry loading deleted notes",resetKeys:[a],children:e.jsx(te,{})})};export{oe as default};
@@ -1,4 +1,4 @@
1
- import{j as y}from"./note-vendor-i1M2FSI2.js";import{h as u,a6 as f,q as n,k as R,m as $}from"./index-BFfQKAUY.js";import{a as l}from"./graph-vendor-CUxe67Lr.js";const g=(e={})=>({limit:e.limit??10,offset:e.offset??0}),D=async(e,t)=>u(`
1
+ import{j as y}from"./note-vendor-i1M2FSI2.js";import{h as u,a6 as f,q as n,k as R,m as $}from"./index-jIfkRdY_.js";import{a as l}from"./graph-vendor-CUxe67Lr.js";const g=(e={})=>({limit:e.limit??10,offset:e.offset??0}),D=async(e,t)=>u(`
2
2
  query FetchNoteReminders($noteId: ID!, $pagination: PaginationInput) {
3
3
  noteReminders(noteId: $noteId, pagination: $pagination) {
4
4
  totalCount
@@ -6,7 +6,7 @@
6
6
  <link rel="icon" type="image/png" href="/icon.png" />
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
8
  <title>Ocean Brain</title>
9
- <script type="module" crossorigin src="/assets/index-BFfQKAUY.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-jIfkRdY_.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/graph-vendor-CUxe67Lr.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/note-core-Z6kqulGB.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/note-vendor-i1M2FSI2.js">
@@ -2,7 +2,7 @@ import express from "express";
2
2
  import { createMcpAdminService } from "./features/mcp-admin/service.js";
3
3
  import { purgeExpiredNoteSnapshots } from "./features/note/services/snapshot.js";
4
4
  import { purgeExpiredTrashedNotes } from "./features/note/services/trash.js";
5
- import { createCsrfProtection, createSessionMiddleware } from "./modules/auth-guard.js";
5
+ import { createSessionMiddleware } from "./modules/auth-guard.js";
6
6
  import { createErrorHandler } from "./modules/error-handler.js";
7
7
  import logger from "./modules/logger.js";
8
8
  import { createApiRouter, createAuthPagesRouter, createClientRouter, createGraphqlRouter } from "./routes/index.js";
@@ -18,7 +18,7 @@ const createAppWithMcpAuth = (authConfig, mcpAdminService) => {
18
18
  process.stderr.write(`[recovery] Startup cleanup failed: ${message}
19
19
  `);
20
20
  });
21
- app.use(logger).use(createSessionMiddleware(authConfig)).use(express.urlencoded({ extended: false })).use(express.json({ limit: "50mb" })).use(createCsrfProtection(authConfig)).use("/api", createApiRouter(authConfig, mcpAdminService)).use(createAuthPagesRouter(authConfig)).use("/graphql", createGraphqlRouter(authConfig, mcpAdminService)).use(createClientRouter(authConfig)).use(createErrorHandler());
21
+ app.use(logger).use(createSessionMiddleware(authConfig)).use(express.urlencoded({ extended: false })).use(express.json({ limit: "50mb" })).use("/api", createApiRouter(authConfig, mcpAdminService)).use(createAuthPagesRouter(authConfig)).use("/graphql", createGraphqlRouter(authConfig, mcpAdminService)).use(createClientRouter(authConfig)).use(createErrorHandler());
22
22
  return app;
23
23
  };
24
24
  var app_default = createApp;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/app.ts"],"sourcesContent":["import express from 'express';\nimport { createMcpAdminService, type McpAdminService } from './features/mcp-admin/service.js';\nimport { purgeExpiredNoteSnapshots } from './features/note/services/snapshot.js';\nimport { purgeExpiredTrashedNotes } from './features/note/services/trash.js';\nimport { createCsrfProtection, createSessionMiddleware } from './modules/auth-guard.js';\nimport type { AuthConfig } from './modules/auth-mode.js';\nimport { createErrorHandler } from './modules/error-handler.js';\nimport logger from './modules/logger.js';\nimport { createApiRouter, createAuthPagesRouter, createClientRouter, createGraphqlRouter } from './routes/index.js';\n\nexport const createApp = (authConfig: AuthConfig) => {\n const mcpAdminService = createMcpAdminService();\n return createAppWithMcpAuth(authConfig, mcpAdminService);\n};\n\nexport const createAppWithMcpAuth = (authConfig: AuthConfig, mcpAdminService: McpAdminService) => {\n const app = express();\n app.locals.authConfig = authConfig;\n\n void Promise.all([purgeExpiredNoteSnapshots(), purgeExpiredTrashedNotes()]).catch((error) => {\n const message = error instanceof Error ? error.message : 'Unknown recovery cleanup error';\n process.stderr.write(`[recovery] Startup cleanup failed: ${message}\\n`);\n });\n\n app.use(logger)\n .use(createSessionMiddleware(authConfig))\n .use(express.urlencoded({ extended: false }))\n .use(express.json({ limit: '50mb' }))\n .use(createCsrfProtection(authConfig))\n .use('/api', createApiRouter(authConfig, mcpAdminService))\n .use(createAuthPagesRouter(authConfig))\n .use('/graphql', createGraphqlRouter(authConfig, mcpAdminService))\n .use(createClientRouter(authConfig))\n .use(createErrorHandler());\n\n return app;\n};\n\nexport default createApp;\n"],"mappings":"AAAA,OAAO,aAAa;AACpB,SAAS,6BAAmD;AAC5D,SAAS,iCAAiC;AAC1C,SAAS,gCAAgC;AACzC,SAAS,sBAAsB,+BAA+B;AAE9D,SAAS,0BAA0B;AACnC,OAAO,YAAY;AACnB,SAAS,iBAAiB,uBAAuB,oBAAoB,2BAA2B;AAEzF,MAAM,YAAY,CAAC,eAA2B;AACjD,QAAM,kBAAkB,sBAAsB;AAC9C,SAAO,qBAAqB,YAAY,eAAe;AAC3D;AAEO,MAAM,uBAAuB,CAAC,YAAwB,oBAAqC;AAC9F,QAAM,MAAM,QAAQ;AACpB,MAAI,OAAO,aAAa;AAExB,OAAK,QAAQ,IAAI,CAAC,0BAA0B,GAAG,yBAAyB,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU;AACzF,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,YAAQ,OAAO,MAAM,sCAAsC,OAAO;AAAA,CAAI;AAAA,EAC1E,CAAC;AAED,MAAI,IAAI,MAAM,EACT,IAAI,wBAAwB,UAAU,CAAC,EACvC,IAAI,QAAQ,WAAW,EAAE,UAAU,MAAM,CAAC,CAAC,EAC3C,IAAI,QAAQ,KAAK,EAAE,OAAO,OAAO,CAAC,CAAC,EACnC,IAAI,qBAAqB,UAAU,CAAC,EACpC,IAAI,QAAQ,gBAAgB,YAAY,eAAe,CAAC,EACxD,IAAI,sBAAsB,UAAU,CAAC,EACrC,IAAI,YAAY,oBAAoB,YAAY,eAAe,CAAC,EAChE,IAAI,mBAAmB,UAAU,CAAC,EAClC,IAAI,mBAAmB,CAAC;AAE7B,SAAO;AACX;AAEA,IAAO,cAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/app.ts"],"sourcesContent":["import express from 'express';\nimport { createMcpAdminService, type McpAdminService } from './features/mcp-admin/service.js';\nimport { purgeExpiredNoteSnapshots } from './features/note/services/snapshot.js';\nimport { purgeExpiredTrashedNotes } from './features/note/services/trash.js';\nimport { createSessionMiddleware } from './modules/auth-guard.js';\nimport type { AuthConfig } from './modules/auth-mode.js';\nimport { createErrorHandler } from './modules/error-handler.js';\nimport logger from './modules/logger.js';\nimport { createApiRouter, createAuthPagesRouter, createClientRouter, createGraphqlRouter } from './routes/index.js';\n\nexport const createApp = (authConfig: AuthConfig) => {\n const mcpAdminService = createMcpAdminService();\n return createAppWithMcpAuth(authConfig, mcpAdminService);\n};\n\nexport const createAppWithMcpAuth = (authConfig: AuthConfig, mcpAdminService: McpAdminService) => {\n const app = express();\n app.locals.authConfig = authConfig;\n\n void Promise.all([purgeExpiredNoteSnapshots(), purgeExpiredTrashedNotes()]).catch((error) => {\n const message = error instanceof Error ? error.message : 'Unknown recovery cleanup error';\n process.stderr.write(`[recovery] Startup cleanup failed: ${message}\\n`);\n });\n\n app.use(logger)\n .use(createSessionMiddleware(authConfig))\n .use(express.urlencoded({ extended: false }))\n .use(express.json({ limit: '50mb' }))\n .use('/api', createApiRouter(authConfig, mcpAdminService))\n .use(createAuthPagesRouter(authConfig))\n .use('/graphql', createGraphqlRouter(authConfig, mcpAdminService))\n .use(createClientRouter(authConfig))\n .use(createErrorHandler());\n\n return app;\n};\n\nexport default createApp;\n"],"mappings":"AAAA,OAAO,aAAa;AACpB,SAAS,6BAAmD;AAC5D,SAAS,iCAAiC;AAC1C,SAAS,gCAAgC;AACzC,SAAS,+BAA+B;AAExC,SAAS,0BAA0B;AACnC,OAAO,YAAY;AACnB,SAAS,iBAAiB,uBAAuB,oBAAoB,2BAA2B;AAEzF,MAAM,YAAY,CAAC,eAA2B;AACjD,QAAM,kBAAkB,sBAAsB;AAC9C,SAAO,qBAAqB,YAAY,eAAe;AAC3D;AAEO,MAAM,uBAAuB,CAAC,YAAwB,oBAAqC;AAC9F,QAAM,MAAM,QAAQ;AACpB,MAAI,OAAO,aAAa;AAExB,OAAK,QAAQ,IAAI,CAAC,0BAA0B,GAAG,yBAAyB,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU;AACzF,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,YAAQ,OAAO,MAAM,sCAAsC,OAAO;AAAA,CAAI;AAAA,EAC1E,CAAC;AAED,MAAI,IAAI,MAAM,EACT,IAAI,wBAAwB,UAAU,CAAC,EACvC,IAAI,QAAQ,WAAW,EAAE,UAAU,MAAM,CAAC,CAAC,EAC3C,IAAI,QAAQ,KAAK,EAAE,OAAO,OAAO,CAAC,CAAC,EACnC,IAAI,QAAQ,gBAAgB,YAAY,eAAe,CAAC,EACxD,IAAI,sBAAsB,UAAU,CAAC,EACrC,IAAI,YAAY,oBAAoB,YAAY,eAAe,CAAC,EAChE,IAAI,mBAAmB,UAAU,CAAC,EAClC,IAAI,mBAAmB,CAAC;AAE7B,SAAO;AACX;AAEA,IAAO,cAAQ;","names":[]}
@@ -5,7 +5,9 @@ import {
5
5
  buildSessionResponse,
6
6
  compareSharedSecret,
7
7
  destroySession,
8
- regenerateSession
8
+ refreshCsrfToken,
9
+ regenerateSession,
10
+ setSessionStatusHeaders
9
11
  } from "../service.js";
10
12
  const createLoginHandler = (authConfig) => {
11
13
  return async (req, res) => {
@@ -16,6 +18,7 @@ const createLoginHandler = (authConfig) => {
16
18
  }
17
19
  await regenerateSession(req);
18
20
  req.session.authenticated = true;
21
+ refreshCsrfToken(req);
19
22
  res.status(200).json(buildSessionResponse(authConfig, req)).end();
20
23
  };
21
24
  };
@@ -29,6 +32,7 @@ const createLogoutHandler = (authConfig) => {
29
32
  };
30
33
  const createSessionStatusHandler = (authConfig) => {
31
34
  return async (req, res) => {
35
+ setSessionStatusHeaders(res);
32
36
  res.status(200).json(buildSessionResponse(authConfig, req)).end();
33
37
  };
34
38
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/features/auth/http/api.ts"],"sourcesContent":["import { buildAuthSessionResponse } from '@baejino/auth';\nimport type { AuthConfig } from '~/modules/auth-mode.js';\nimport { createAppError } from '~/modules/error-handler.js';\nimport type { Controller } from '~/types/index.js';\nimport {\n assertPasswordLoginAvailable,\n buildSessionResponse,\n compareSharedSecret,\n destroySession,\n regenerateSession,\n} from '../service.js';\n\nexport const createLoginHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n const expectedPassword = assertPasswordLoginAvailable(authConfig);\n const password = typeof req.body?.password === 'string' ? req.body.password : '';\n\n if (!password || !compareSharedSecret(expectedPassword, password)) {\n throw createAppError(401, 'UNAUTHORIZED', 'Invalid password');\n }\n\n await regenerateSession(req);\n req.session.authenticated = true;\n\n res.status(200).json(buildSessionResponse(authConfig, req)).end();\n };\n};\n\nexport const createLogoutHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n if (authConfig.mode === 'password') {\n await destroySession(req);\n }\n\n res.status(200).json(buildAuthSessionResponse(authConfig, false)).end();\n };\n};\n\nexport const createSessionStatusHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n res.status(200).json(buildSessionResponse(authConfig, req)).end();\n };\n};\n"],"mappings":"AAAA,SAAS,gCAAgC;AAEzC,SAAS,sBAAsB;AAE/B;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEA,MAAM,qBAAqB,CAAC,eAAuC;AACtE,SAAO,OAAO,KAAK,QAAQ;AACvB,UAAM,mBAAmB,6BAA6B,UAAU;AAChE,UAAM,WAAW,OAAO,IAAI,MAAM,aAAa,WAAW,IAAI,KAAK,WAAW;AAE9E,QAAI,CAAC,YAAY,CAAC,oBAAoB,kBAAkB,QAAQ,GAAG;AAC/D,YAAM,eAAe,KAAK,gBAAgB,kBAAkB;AAAA,IAChE;AAEA,UAAM,kBAAkB,GAAG;AAC3B,QAAI,QAAQ,gBAAgB;AAE5B,QAAI,OAAO,GAAG,EAAE,KAAK,qBAAqB,YAAY,GAAG,CAAC,EAAE,IAAI;AAAA,EACpE;AACJ;AAEO,MAAM,sBAAsB,CAAC,eAAuC;AACvE,SAAO,OAAO,KAAK,QAAQ;AACvB,QAAI,WAAW,SAAS,YAAY;AAChC,YAAM,eAAe,GAAG;AAAA,IAC5B;AAEA,QAAI,OAAO,GAAG,EAAE,KAAK,yBAAyB,YAAY,KAAK,CAAC,EAAE,IAAI;AAAA,EAC1E;AACJ;AAEO,MAAM,6BAA6B,CAAC,eAAuC;AAC9E,SAAO,OAAO,KAAK,QAAQ;AACvB,QAAI,OAAO,GAAG,EAAE,KAAK,qBAAqB,YAAY,GAAG,CAAC,EAAE,IAAI;AAAA,EACpE;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/features/auth/http/api.ts"],"sourcesContent":["import { buildAuthSessionResponse } from '@baejino/auth';\nimport type { AuthConfig } from '~/modules/auth-mode.js';\nimport { createAppError } from '~/modules/error-handler.js';\nimport type { Controller } from '~/types/index.js';\nimport {\n assertPasswordLoginAvailable,\n buildSessionResponse,\n compareSharedSecret,\n destroySession,\n refreshCsrfToken,\n regenerateSession,\n setSessionStatusHeaders,\n} from '../service.js';\n\nexport const createLoginHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n const expectedPassword = assertPasswordLoginAvailable(authConfig);\n const password = typeof req.body?.password === 'string' ? req.body.password : '';\n\n if (!password || !compareSharedSecret(expectedPassword, password)) {\n throw createAppError(401, 'UNAUTHORIZED', 'Invalid password');\n }\n\n await regenerateSession(req);\n req.session.authenticated = true;\n refreshCsrfToken(req);\n\n res.status(200).json(buildSessionResponse(authConfig, req)).end();\n };\n};\n\nexport const createLogoutHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n if (authConfig.mode === 'password') {\n await destroySession(req);\n }\n\n res.status(200).json(buildAuthSessionResponse(authConfig, false)).end();\n };\n};\n\nexport const createSessionStatusHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n setSessionStatusHeaders(res);\n res.status(200).json(buildSessionResponse(authConfig, req)).end();\n };\n};\n"],"mappings":"AAAA,SAAS,gCAAgC;AAEzC,SAAS,sBAAsB;AAE/B;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEA,MAAM,qBAAqB,CAAC,eAAuC;AACtE,SAAO,OAAO,KAAK,QAAQ;AACvB,UAAM,mBAAmB,6BAA6B,UAAU;AAChE,UAAM,WAAW,OAAO,IAAI,MAAM,aAAa,WAAW,IAAI,KAAK,WAAW;AAE9E,QAAI,CAAC,YAAY,CAAC,oBAAoB,kBAAkB,QAAQ,GAAG;AAC/D,YAAM,eAAe,KAAK,gBAAgB,kBAAkB;AAAA,IAChE;AAEA,UAAM,kBAAkB,GAAG;AAC3B,QAAI,QAAQ,gBAAgB;AAC5B,qBAAiB,GAAG;AAEpB,QAAI,OAAO,GAAG,EAAE,KAAK,qBAAqB,YAAY,GAAG,CAAC,EAAE,IAAI;AAAA,EACpE;AACJ;AAEO,MAAM,sBAAsB,CAAC,eAAuC;AACvE,SAAO,OAAO,KAAK,QAAQ;AACvB,QAAI,WAAW,SAAS,YAAY;AAChC,YAAM,eAAe,GAAG;AAAA,IAC5B;AAEA,QAAI,OAAO,GAAG,EAAE,KAAK,yBAAyB,YAAY,KAAK,CAAC,EAAE,IAAI;AAAA,EAC1E;AACJ;AAEO,MAAM,6BAA6B,CAAC,eAAuC;AAC9E,SAAO,OAAO,KAAK,QAAQ;AACvB,4BAAwB,GAAG;AAC3B,QAAI,OAAO,GAAG,EAAE,KAAK,qBAAqB,YAAY,GAAG,CAAC,EAAE,IAAI;AAAA,EACpE;AACJ;","names":[]}
@@ -1,4 +1,10 @@
1
- import { compareSharedSecret, destroySession, regenerateSession, sanitizeRedirectPath } from "../service.js";
1
+ import {
2
+ compareSharedSecret,
3
+ destroySession,
4
+ refreshCsrfToken,
5
+ regenerateSession,
6
+ sanitizeRedirectPath
7
+ } from "../service.js";
2
8
  import { renderLoginPage } from "./login-page.js";
3
9
  const createLoginPageHandler = (authConfig) => {
4
10
  return async (req, res) => {
@@ -30,6 +36,7 @@ const createLoginPageSubmitHandler = (authConfig) => {
30
36
  }
31
37
  await regenerateSession(req);
32
38
  req.session.authenticated = true;
39
+ refreshCsrfToken(req);
33
40
  res.redirect(303, nextPath);
34
41
  };
35
42
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/features/auth/http/pages.ts"],"sourcesContent":["import type { AuthConfig } from '~/modules/auth-mode.js';\nimport type { Controller } from '~/types/index.js';\nimport { compareSharedSecret, destroySession, regenerateSession, sanitizeRedirectPath } from '../service.js';\nimport { renderLoginPage } from './login-page.js';\n\nexport const createLoginPageHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n if (authConfig.mode !== 'password' || req.session?.authenticated) {\n res.redirect(303, sanitizeRedirectPath(req.query.next));\n return;\n }\n\n const nextPath = sanitizeRedirectPath(req.query.next);\n res.status(200)\n .type('html')\n .send(renderLoginPage({ nextPath, csrfToken: res.locals._csrf }))\n .end();\n };\n};\n\nexport const createLoginPageSubmitHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n const nextPath = sanitizeRedirectPath(req.body?.next);\n\n if (authConfig.mode !== 'password' || !authConfig.password) {\n res.redirect(303, nextPath);\n return;\n }\n\n const password = typeof req.body?.password === 'string' ? req.body.password : '';\n\n if (!password || !compareSharedSecret(authConfig.password, password)) {\n res.status(401)\n .type('html')\n .send(\n renderLoginPage({\n nextPath,\n errorMessage: 'Invalid password',\n csrfToken: res.locals._csrf,\n }),\n )\n .end();\n return;\n }\n\n await regenerateSession(req);\n req.session.authenticated = true;\n\n res.redirect(303, nextPath);\n };\n};\n\nexport const createLogoutPageHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n if (authConfig.mode === 'password') {\n await destroySession(req);\n res.redirect(303, '/login');\n return;\n }\n\n res.redirect(303, '/');\n };\n};\n"],"mappings":"AAEA,SAAS,qBAAqB,gBAAgB,mBAAmB,4BAA4B;AAC7F,SAAS,uBAAuB;AAEzB,MAAM,yBAAyB,CAAC,eAAuC;AAC1E,SAAO,OAAO,KAAK,QAAQ;AACvB,QAAI,WAAW,SAAS,cAAc,IAAI,SAAS,eAAe;AAC9D,UAAI,SAAS,KAAK,qBAAqB,IAAI,MAAM,IAAI,CAAC;AACtD;AAAA,IACJ;AAEA,UAAM,WAAW,qBAAqB,IAAI,MAAM,IAAI;AACpD,QAAI,OAAO,GAAG,EACT,KAAK,MAAM,EACX,KAAK,gBAAgB,EAAE,UAAU,WAAW,IAAI,OAAO,MAAM,CAAC,CAAC,EAC/D,IAAI;AAAA,EACb;AACJ;AAEO,MAAM,+BAA+B,CAAC,eAAuC;AAChF,SAAO,OAAO,KAAK,QAAQ;AACvB,UAAM,WAAW,qBAAqB,IAAI,MAAM,IAAI;AAEpD,QAAI,WAAW,SAAS,cAAc,CAAC,WAAW,UAAU;AACxD,UAAI,SAAS,KAAK,QAAQ;AAC1B;AAAA,IACJ;AAEA,UAAM,WAAW,OAAO,IAAI,MAAM,aAAa,WAAW,IAAI,KAAK,WAAW;AAE9E,QAAI,CAAC,YAAY,CAAC,oBAAoB,WAAW,UAAU,QAAQ,GAAG;AAClE,UAAI,OAAO,GAAG,EACT,KAAK,MAAM,EACX;AAAA,QACG,gBAAgB;AAAA,UACZ;AAAA,UACA,cAAc;AAAA,UACd,WAAW,IAAI,OAAO;AAAA,QAC1B,CAAC;AAAA,MACL,EACC,IAAI;AACT;AAAA,IACJ;AAEA,UAAM,kBAAkB,GAAG;AAC3B,QAAI,QAAQ,gBAAgB;AAE5B,QAAI,SAAS,KAAK,QAAQ;AAAA,EAC9B;AACJ;AAEO,MAAM,0BAA0B,CAAC,eAAuC;AAC3E,SAAO,OAAO,KAAK,QAAQ;AACvB,QAAI,WAAW,SAAS,YAAY;AAChC,YAAM,eAAe,GAAG;AACxB,UAAI,SAAS,KAAK,QAAQ;AAC1B;AAAA,IACJ;AAEA,QAAI,SAAS,KAAK,GAAG;AAAA,EACzB;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/features/auth/http/pages.ts"],"sourcesContent":["import type { AuthConfig } from '~/modules/auth-mode.js';\nimport type { Controller } from '~/types/index.js';\nimport {\n compareSharedSecret,\n destroySession,\n refreshCsrfToken,\n regenerateSession,\n sanitizeRedirectPath,\n} from '../service.js';\nimport { renderLoginPage } from './login-page.js';\n\nexport const createLoginPageHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n if (authConfig.mode !== 'password' || req.session?.authenticated) {\n res.redirect(303, sanitizeRedirectPath(req.query.next));\n return;\n }\n\n const nextPath = sanitizeRedirectPath(req.query.next);\n res.status(200)\n .type('html')\n .send(renderLoginPage({ nextPath, csrfToken: res.locals._csrf }))\n .end();\n };\n};\n\nexport const createLoginPageSubmitHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n const nextPath = sanitizeRedirectPath(req.body?.next);\n\n if (authConfig.mode !== 'password' || !authConfig.password) {\n res.redirect(303, nextPath);\n return;\n }\n\n const password = typeof req.body?.password === 'string' ? req.body.password : '';\n\n if (!password || !compareSharedSecret(authConfig.password, password)) {\n res.status(401)\n .type('html')\n .send(\n renderLoginPage({\n nextPath,\n errorMessage: 'Invalid password',\n csrfToken: res.locals._csrf,\n }),\n )\n .end();\n return;\n }\n\n await regenerateSession(req);\n req.session.authenticated = true;\n refreshCsrfToken(req);\n\n res.redirect(303, nextPath);\n };\n};\n\nexport const createLogoutPageHandler = (authConfig: AuthConfig): Controller => {\n return async (req, res) => {\n if (authConfig.mode === 'password') {\n await destroySession(req);\n res.redirect(303, '/login');\n return;\n }\n\n res.redirect(303, '/');\n };\n};\n"],"mappings":"AAEA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,uBAAuB;AAEzB,MAAM,yBAAyB,CAAC,eAAuC;AAC1E,SAAO,OAAO,KAAK,QAAQ;AACvB,QAAI,WAAW,SAAS,cAAc,IAAI,SAAS,eAAe;AAC9D,UAAI,SAAS,KAAK,qBAAqB,IAAI,MAAM,IAAI,CAAC;AACtD;AAAA,IACJ;AAEA,UAAM,WAAW,qBAAqB,IAAI,MAAM,IAAI;AACpD,QAAI,OAAO,GAAG,EACT,KAAK,MAAM,EACX,KAAK,gBAAgB,EAAE,UAAU,WAAW,IAAI,OAAO,MAAM,CAAC,CAAC,EAC/D,IAAI;AAAA,EACb;AACJ;AAEO,MAAM,+BAA+B,CAAC,eAAuC;AAChF,SAAO,OAAO,KAAK,QAAQ;AACvB,UAAM,WAAW,qBAAqB,IAAI,MAAM,IAAI;AAEpD,QAAI,WAAW,SAAS,cAAc,CAAC,WAAW,UAAU;AACxD,UAAI,SAAS,KAAK,QAAQ;AAC1B;AAAA,IACJ;AAEA,UAAM,WAAW,OAAO,IAAI,MAAM,aAAa,WAAW,IAAI,KAAK,WAAW;AAE9E,QAAI,CAAC,YAAY,CAAC,oBAAoB,WAAW,UAAU,QAAQ,GAAG;AAClE,UAAI,OAAO,GAAG,EACT,KAAK,MAAM,EACX;AAAA,QACG,gBAAgB;AAAA,UACZ;AAAA,UACA,cAAc;AAAA,UACd,WAAW,IAAI,OAAO;AAAA,QAC1B,CAAC;AAAA,MACL,EACC,IAAI;AACT;AAAA,IACJ;AAEA,UAAM,kBAAkB,GAAG;AAC3B,QAAI,QAAQ,gBAAgB;AAC5B,qBAAiB,GAAG;AAEpB,QAAI,SAAS,KAAK,QAAQ;AAAA,EAC9B;AACJ;AAEO,MAAM,0BAA0B,CAAC,eAAuC;AAC3E,SAAO,OAAO,KAAK,QAAQ;AACvB,QAAI,WAAW,SAAS,YAAY;AAChC,YAAM,eAAe,GAAG;AACxB,UAAI,SAAS,KAAK,QAAQ;AAC1B;AAAA,IACJ;AAEA,QAAI,SAAS,KAAK,GAAG;AAAA,EACzB;AACJ;","names":[]}
@@ -1,7 +1,10 @@
1
- import { buildAuthSessionResponse, sanitizeRedirectPath as sanitizeCommonRedirectPath } from "@baejino/auth";
1
+ import { buildAuthSessionResponse } from "@baejino/auth";
2
2
  import { compareSharedSecret as compareCommonSharedSecret } from "@baejino/auth/crypto";
3
3
  import crypto from "crypto";
4
+ import { sanitizeRedirectPath } from "../../modules/auth-redirect.js";
4
5
  import { createAppError } from "../../modules/error-handler.js";
6
+ const AUTH_SESSION_GENERATION_HEADER = "X-Ocean-Brain-Session-Generation";
7
+ const AUTH_SESSION_GENERATION = crypto.randomUUID();
5
8
  const createPasswordHash = async (password) => {
6
9
  const salt = crypto.randomBytes(16).toString("hex");
7
10
  const hash = crypto.pbkdf2Sync(password, salt, 1e3, 64, "sha512").toString("hex");
@@ -14,6 +17,14 @@ const comparePassword = async (password, storedHash) => {
14
17
  };
15
18
  const compareSharedSecret = compareCommonSharedSecret;
16
19
  const buildSessionResponse = (authConfig, req) => buildAuthSessionResponse(authConfig, Boolean(req.session?.authenticated));
20
+ const setSessionStatusHeaders = (res) => {
21
+ res.set(AUTH_SESSION_GENERATION_HEADER, AUTH_SESSION_GENERATION);
22
+ res.set("Cache-Control", "no-store");
23
+ };
24
+ const refreshCsrfToken = (req) => {
25
+ const requestWithCsrf = req;
26
+ requestWithCsrf.csrfToken?.();
27
+ };
17
28
  const assertPasswordLoginAvailable = (authConfig) => {
18
29
  if (authConfig.mode !== "password") {
19
30
  throw createAppError(409, "AUTH_OPEN_MODE", "Login is unavailable while auth mode is open.");
@@ -45,19 +56,17 @@ const destroySession = async (req) => {
45
56
  });
46
57
  });
47
58
  };
48
- const sanitizeRedirectPath = (value) => sanitizeCommonRedirectPath(value, {
49
- fallbackPath: "/",
50
- loginPath: "/login",
51
- allowedAbsoluteHosts: ["localhost", "127.0.0.1", "::1"]
52
- });
53
59
  export {
60
+ AUTH_SESSION_GENERATION_HEADER,
54
61
  assertPasswordLoginAvailable,
55
62
  buildSessionResponse,
56
63
  comparePassword,
57
64
  compareSharedSecret,
58
65
  createPasswordHash,
59
66
  destroySession,
67
+ refreshCsrfToken,
60
68
  regenerateSession,
61
- sanitizeRedirectPath
69
+ sanitizeRedirectPath,
70
+ setSessionStatusHeaders
62
71
  };
63
72
  //# sourceMappingURL=service.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/auth/service.ts"],"sourcesContent":["import { buildAuthSessionResponse, sanitizeRedirectPath as sanitizeCommonRedirectPath } from '@baejino/auth';\nimport { compareSharedSecret as compareCommonSharedSecret } from '@baejino/auth/crypto';\nimport crypto from 'crypto';\nimport type { Request } from 'express';\nimport type { AuthConfig } from '~/modules/auth-mode.js';\nimport { createAppError } from '~/modules/error-handler.js';\n\nexport const createPasswordHash = async (password: string) => {\n const salt = crypto.randomBytes(16).toString('hex');\n const hash = crypto.pbkdf2Sync(password, salt, 1000, 64, 'sha512').toString('hex');\n return `${salt}:${hash}`;\n};\n\nexport const comparePassword = async (password: string, storedHash: string) => {\n const [salt, hash] = storedHash.split(':');\n const newHash = crypto.pbkdf2Sync(password, salt, 1000, 64, 'sha512').toString('hex');\n return hash === newHash;\n};\n\nexport const compareSharedSecret = compareCommonSharedSecret;\n\nexport const buildSessionResponse = (authConfig: AuthConfig, req: Request) =>\n buildAuthSessionResponse(authConfig, Boolean(req.session?.authenticated));\n\nexport const assertPasswordLoginAvailable = (authConfig: AuthConfig) => {\n if (authConfig.mode !== 'password') {\n throw createAppError(409, 'AUTH_OPEN_MODE', 'Login is unavailable while auth mode is open.');\n }\n\n return authConfig.password;\n};\n\nexport const regenerateSession = async (req: Request) => {\n await new Promise<void>((resolve, reject) => {\n req.session.regenerate((error) => {\n if (error) {\n reject(error);\n return;\n }\n\n resolve();\n });\n });\n};\n\nexport const destroySession = async (req: Request) => {\n if (!req.session) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n req.session.destroy((error) => {\n if (error) {\n reject(error);\n return;\n }\n\n resolve();\n });\n });\n};\n\nexport const sanitizeRedirectPath = (value: unknown) =>\n sanitizeCommonRedirectPath(value, {\n fallbackPath: '/',\n loginPath: '/login',\n allowedAbsoluteHosts: ['localhost', '127.0.0.1', '::1'],\n });\n"],"mappings":"AAAA,SAAS,0BAA0B,wBAAwB,kCAAkC;AAC7F,SAAS,uBAAuB,iCAAiC;AACjE,OAAO,YAAY;AAGnB,SAAS,sBAAsB;AAExB,MAAM,qBAAqB,OAAO,aAAqB;AAC1D,QAAM,OAAO,OAAO,YAAY,EAAE,EAAE,SAAS,KAAK;AAClD,QAAM,OAAO,OAAO,WAAW,UAAU,MAAM,KAAM,IAAI,QAAQ,EAAE,SAAS,KAAK;AACjF,SAAO,GAAG,IAAI,IAAI,IAAI;AAC1B;AAEO,MAAM,kBAAkB,OAAO,UAAkB,eAAuB;AAC3E,QAAM,CAAC,MAAM,IAAI,IAAI,WAAW,MAAM,GAAG;AACzC,QAAM,UAAU,OAAO,WAAW,UAAU,MAAM,KAAM,IAAI,QAAQ,EAAE,SAAS,KAAK;AACpF,SAAO,SAAS;AACpB;AAEO,MAAM,sBAAsB;AAE5B,MAAM,uBAAuB,CAAC,YAAwB,QACzD,yBAAyB,YAAY,QAAQ,IAAI,SAAS,aAAa,CAAC;AAErE,MAAM,+BAA+B,CAAC,eAA2B;AACpE,MAAI,WAAW,SAAS,YAAY;AAChC,UAAM,eAAe,KAAK,kBAAkB,+CAA+C;AAAA,EAC/F;AAEA,SAAO,WAAW;AACtB;AAEO,MAAM,oBAAoB,OAAO,QAAiB;AACrD,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AACzC,QAAI,QAAQ,WAAW,CAAC,UAAU;AAC9B,UAAI,OAAO;AACP,eAAO,KAAK;AACZ;AAAA,MACJ;AAEA,cAAQ;AAAA,IACZ,CAAC;AAAA,EACL,CAAC;AACL;AAEO,MAAM,iBAAiB,OAAO,QAAiB;AAClD,MAAI,CAAC,IAAI,SAAS;AACd;AAAA,EACJ;AAEA,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AACzC,QAAI,QAAQ,QAAQ,CAAC,UAAU;AAC3B,UAAI,OAAO;AACP,eAAO,KAAK;AACZ;AAAA,MACJ;AAEA,cAAQ;AAAA,IACZ,CAAC;AAAA,EACL,CAAC;AACL;AAEO,MAAM,uBAAuB,CAAC,UACjC,2BAA2B,OAAO;AAAA,EAC9B,cAAc;AAAA,EACd,WAAW;AAAA,EACX,sBAAsB,CAAC,aAAa,aAAa,KAAK;AAC1D,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../src/features/auth/service.ts"],"sourcesContent":["import { buildAuthSessionResponse } from '@baejino/auth';\nimport { compareSharedSecret as compareCommonSharedSecret } from '@baejino/auth/crypto';\nimport crypto from 'crypto';\nimport type { Request, Response } from 'express';\nimport type { AuthConfig } from '~/modules/auth-mode.js';\nimport { sanitizeRedirectPath } from '~/modules/auth-redirect.js';\nimport { createAppError } from '~/modules/error-handler.js';\n\nexport const AUTH_SESSION_GENERATION_HEADER = 'X-Ocean-Brain-Session-Generation';\nconst AUTH_SESSION_GENERATION = crypto.randomUUID();\n\nexport const createPasswordHash = async (password: string) => {\n const salt = crypto.randomBytes(16).toString('hex');\n const hash = crypto.pbkdf2Sync(password, salt, 1000, 64, 'sha512').toString('hex');\n return `${salt}:${hash}`;\n};\n\nexport const comparePassword = async (password: string, storedHash: string) => {\n const [salt, hash] = storedHash.split(':');\n const newHash = crypto.pbkdf2Sync(password, salt, 1000, 64, 'sha512').toString('hex');\n return hash === newHash;\n};\n\nexport const compareSharedSecret = compareCommonSharedSecret;\n\nexport const buildSessionResponse = (authConfig: AuthConfig, req: Request) =>\n buildAuthSessionResponse(authConfig, Boolean(req.session?.authenticated));\n\nexport const setSessionStatusHeaders = (res: Response) => {\n res.set(AUTH_SESSION_GENERATION_HEADER, AUTH_SESSION_GENERATION);\n res.set('Cache-Control', 'no-store');\n};\n\nexport const refreshCsrfToken = (req: Request) => {\n const requestWithCsrf = req as Request & { csrfToken?: () => string };\n requestWithCsrf.csrfToken?.();\n};\n\nexport const assertPasswordLoginAvailable = (authConfig: AuthConfig) => {\n if (authConfig.mode !== 'password') {\n throw createAppError(409, 'AUTH_OPEN_MODE', 'Login is unavailable while auth mode is open.');\n }\n\n return authConfig.password;\n};\n\nexport const regenerateSession = async (req: Request) => {\n await new Promise<void>((resolve, reject) => {\n req.session.regenerate((error) => {\n if (error) {\n reject(error);\n return;\n }\n\n resolve();\n });\n });\n};\n\nexport const destroySession = async (req: Request) => {\n if (!req.session) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n req.session.destroy((error) => {\n if (error) {\n reject(error);\n return;\n }\n\n resolve();\n });\n });\n};\n\nexport { sanitizeRedirectPath };\n"],"mappings":"AAAA,SAAS,gCAAgC;AACzC,SAAS,uBAAuB,iCAAiC;AACjE,OAAO,YAAY;AAGnB,SAAS,4BAA4B;AACrC,SAAS,sBAAsB;AAExB,MAAM,iCAAiC;AAC9C,MAAM,0BAA0B,OAAO,WAAW;AAE3C,MAAM,qBAAqB,OAAO,aAAqB;AAC1D,QAAM,OAAO,OAAO,YAAY,EAAE,EAAE,SAAS,KAAK;AAClD,QAAM,OAAO,OAAO,WAAW,UAAU,MAAM,KAAM,IAAI,QAAQ,EAAE,SAAS,KAAK;AACjF,SAAO,GAAG,IAAI,IAAI,IAAI;AAC1B;AAEO,MAAM,kBAAkB,OAAO,UAAkB,eAAuB;AAC3E,QAAM,CAAC,MAAM,IAAI,IAAI,WAAW,MAAM,GAAG;AACzC,QAAM,UAAU,OAAO,WAAW,UAAU,MAAM,KAAM,IAAI,QAAQ,EAAE,SAAS,KAAK;AACpF,SAAO,SAAS;AACpB;AAEO,MAAM,sBAAsB;AAE5B,MAAM,uBAAuB,CAAC,YAAwB,QACzD,yBAAyB,YAAY,QAAQ,IAAI,SAAS,aAAa,CAAC;AAErE,MAAM,0BAA0B,CAAC,QAAkB;AACtD,MAAI,IAAI,gCAAgC,uBAAuB;AAC/D,MAAI,IAAI,iBAAiB,UAAU;AACvC;AAEO,MAAM,mBAAmB,CAAC,QAAiB;AAC9C,QAAM,kBAAkB;AACxB,kBAAgB,YAAY;AAChC;AAEO,MAAM,+BAA+B,CAAC,eAA2B;AACpE,MAAI,WAAW,SAAS,YAAY;AAChC,UAAM,eAAe,KAAK,kBAAkB,+CAA+C;AAAA,EAC/F;AAEA,SAAO,WAAW;AACtB;AAEO,MAAM,oBAAoB,OAAO,QAAiB;AACrD,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AACzC,QAAI,QAAQ,WAAW,CAAC,UAAU;AAC9B,UAAI,OAAO;AACP,eAAO,KAAK;AACZ;AAAA,MACJ;AAEA,cAAQ;AAAA,IACZ,CAAC;AAAA,EACL,CAAC;AACL;AAEO,MAAM,iBAAiB,OAAO,QAAiB;AAClD,MAAI,CAAC,IAAI,SAAS;AACd;AAAA,EACJ;AAEA,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AACzC,QAAI,QAAQ,QAAQ,CAAC,UAAU;AAC3B,UAAI,OAAO;AACP,eAAO,KAAK;AACZ;AAAA,MACJ;AAEA,cAAQ;AAAA,IACZ,CAAC;AAAA,EACL,CAAC;AACL;","names":[]}
@@ -2,6 +2,8 @@ import { buildUnauthorizedGraphqlPayload, buildUnauthorizedPayload } from "@baej
2
2
  import session from "express-session";
3
3
  import { GraphQLError } from "graphql";
4
4
  import lusca from "lusca";
5
+ import { sanitizeRedirectPath } from "./auth-redirect.js";
6
+ import { AUTH_SESSION_IDLE_TIMEOUT_MS, createSessionStore } from "./session-store.js";
5
7
  const JSON_HEADERS = { "Content-Type": "application/json" };
6
8
  const isAuthenticatedRequest = (req) => Boolean(req.session?.authenticated);
7
9
  const createSessionMiddleware = (authConfig) => {
@@ -11,9 +13,12 @@ const createSessionMiddleware = (authConfig) => {
11
13
  return session({
12
14
  secret: authConfig.sessionSecret,
13
15
  name: authConfig.cookieName,
16
+ store: createSessionStore(),
14
17
  resave: false,
15
18
  saveUninitialized: false,
19
+ rolling: true,
16
20
  cookie: {
21
+ maxAge: AUTH_SESSION_IDLE_TIMEOUT_MS,
17
22
  httpOnly: true,
18
23
  sameSite: "lax",
19
24
  secure: process.env.NODE_ENV === "production",
@@ -33,10 +38,23 @@ const createCsrfProtection = (authConfig) => {
33
38
  sameSite: "lax",
34
39
  secure: process.env.NODE_ENV === "production"
35
40
  }
36
- },
37
- blocklist: ["/api/mcp", "/graphql/mcp"]
41
+ }
38
42
  });
39
43
  };
44
+ const isCsrfTokenError = (error) => error instanceof Error && error.message.startsWith("CSRF token ");
45
+ const buildLoginRedirectPath = (req) => {
46
+ const nextPath = sanitizeRedirectPath(req.body?.next);
47
+ return `/login?next=${encodeURIComponent(nextPath)}`;
48
+ };
49
+ const createLoginCsrfFailureHandler = (authConfig) => {
50
+ return (error, req, res, next) => {
51
+ if (authConfig.mode !== "password" || !isCsrfTokenError(error) || req.method !== "POST" || req.path !== "/login" || isAuthenticatedRequest(req)) {
52
+ next(error);
53
+ return;
54
+ }
55
+ res.redirect(303, buildLoginRedirectPath(req));
56
+ };
57
+ };
40
58
  const requireSessionForWrite = (authConfig) => {
41
59
  return (req, res, next) => {
42
60
  if (authConfig.mode === "open" || isAuthenticatedRequest(req)) {
@@ -77,6 +95,7 @@ const createMutationAuthValidationRule = () => {
77
95
  };
78
96
  export {
79
97
  createCsrfProtection,
98
+ createLoginCsrfFailureHandler,
80
99
  createMutationAuthValidationRule,
81
100
  createSessionMiddleware,
82
101
  isAuthenticatedRequest,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/modules/auth-guard.ts"],"sourcesContent":["import { buildUnauthorizedGraphqlPayload, buildUnauthorizedPayload } from '@baejino/auth';\nimport type { NextFunction, Request, RequestHandler, Response } from 'express';\nimport session from 'express-session';\nimport type { ValidationRule } from 'graphql';\nimport { GraphQLError } from 'graphql';\nimport lusca from 'lusca';\n\nimport type { AuthConfig } from './auth-mode.js';\n\nconst JSON_HEADERS = { 'Content-Type': 'application/json' };\n\nexport const isAuthenticatedRequest = (req: Request) => Boolean(req.session?.authenticated);\n\nexport const createSessionMiddleware = (authConfig: AuthConfig): RequestHandler => {\n if (authConfig.mode !== 'password') {\n return (_req, _res, next) => next();\n }\n\n return session({\n secret: authConfig.sessionSecret,\n name: authConfig.cookieName,\n resave: false,\n saveUninitialized: false,\n cookie: {\n httpOnly: true,\n sameSite: 'lax',\n secure: process.env.NODE_ENV === 'production',\n path: '/',\n },\n });\n};\n\nexport const createCsrfProtection = (authConfig: AuthConfig): RequestHandler => {\n if (authConfig.mode !== 'password') {\n return (_req, _res, next) => next();\n }\n\n return lusca.csrf({\n angular: true,\n cookie: {\n options: {\n path: '/',\n sameSite: 'lax',\n secure: process.env.NODE_ENV === 'production',\n },\n },\n blocklist: ['/api/mcp', '/graphql/mcp'],\n });\n};\n\nexport const requireSessionForWrite = (authConfig: AuthConfig): RequestHandler => {\n return (req: Request, res: Response, next: NextFunction) => {\n if (authConfig.mode === 'open' || isAuthenticatedRequest(req)) {\n next();\n return;\n }\n\n res.status(401).set(JSON_HEADERS).json(buildUnauthorizedPayload()).end();\n };\n};\n\nexport const requireSessionForGraphql = (authConfig: AuthConfig): RequestHandler => {\n return (req: Request, res: Response, next: NextFunction) => {\n if (authConfig.mode === 'open' || isAuthenticatedRequest(req)) {\n next();\n return;\n }\n\n res.status(401).set(JSON_HEADERS).json(buildUnauthorizedGraphqlPayload()).end();\n };\n};\n\nexport const createMutationAuthValidationRule = (): ValidationRule => {\n return (context) => {\n return {\n OperationDefinition(node) {\n if (node.operation !== 'mutation') {\n return;\n }\n\n const unauthorizedError = buildUnauthorizedGraphqlPayload().errors[0];\n\n context.reportError(\n new GraphQLError(unauthorizedError.message, {\n nodes: [node],\n extensions: {\n code: unauthorizedError.extensions.code,\n },\n }),\n );\n },\n };\n };\n};\n"],"mappings":"AAAA,SAAS,iCAAiC,gCAAgC;AAE1E,OAAO,aAAa;AAEpB,SAAS,oBAAoB;AAC7B,OAAO,WAAW;AAIlB,MAAM,eAAe,EAAE,gBAAgB,mBAAmB;AAEnD,MAAM,yBAAyB,CAAC,QAAiB,QAAQ,IAAI,SAAS,aAAa;AAEnF,MAAM,0BAA0B,CAAC,eAA2C;AAC/E,MAAI,WAAW,SAAS,YAAY;AAChC,WAAO,CAAC,MAAM,MAAM,SAAS,KAAK;AAAA,EACtC;AAEA,SAAO,QAAQ;AAAA,IACX,QAAQ,WAAW;AAAA,IACnB,MAAM,WAAW;AAAA,IACjB,QAAQ;AAAA,IACR,mBAAmB;AAAA,IACnB,QAAQ;AAAA,MACJ,UAAU;AAAA,MACV,UAAU;AAAA,MACV,QAAQ,QAAQ,IAAI,aAAa;AAAA,MACjC,MAAM;AAAA,IACV;AAAA,EACJ,CAAC;AACL;AAEO,MAAM,uBAAuB,CAAC,eAA2C;AAC5E,MAAI,WAAW,SAAS,YAAY;AAChC,WAAO,CAAC,MAAM,MAAM,SAAS,KAAK;AAAA,EACtC;AAEA,SAAO,MAAM,KAAK;AAAA,IACd,SAAS;AAAA,IACT,QAAQ;AAAA,MACJ,SAAS;AAAA,QACL,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQ,QAAQ,IAAI,aAAa;AAAA,MACrC;AAAA,IACJ;AAAA,IACA,WAAW,CAAC,YAAY,cAAc;AAAA,EAC1C,CAAC;AACL;AAEO,MAAM,yBAAyB,CAAC,eAA2C;AAC9E,SAAO,CAAC,KAAc,KAAe,SAAuB;AACxD,QAAI,WAAW,SAAS,UAAU,uBAAuB,GAAG,GAAG;AAC3D,WAAK;AACL;AAAA,IACJ;AAEA,QAAI,OAAO,GAAG,EAAE,IAAI,YAAY,EAAE,KAAK,yBAAyB,CAAC,EAAE,IAAI;AAAA,EAC3E;AACJ;AAEO,MAAM,2BAA2B,CAAC,eAA2C;AAChF,SAAO,CAAC,KAAc,KAAe,SAAuB;AACxD,QAAI,WAAW,SAAS,UAAU,uBAAuB,GAAG,GAAG;AAC3D,WAAK;AACL;AAAA,IACJ;AAEA,QAAI,OAAO,GAAG,EAAE,IAAI,YAAY,EAAE,KAAK,gCAAgC,CAAC,EAAE,IAAI;AAAA,EAClF;AACJ;AAEO,MAAM,mCAAmC,MAAsB;AAClE,SAAO,CAAC,YAAY;AAChB,WAAO;AAAA,MACH,oBAAoB,MAAM;AACtB,YAAI,KAAK,cAAc,YAAY;AAC/B;AAAA,QACJ;AAEA,cAAM,oBAAoB,gCAAgC,EAAE,OAAO,CAAC;AAEpE,gBAAQ;AAAA,UACJ,IAAI,aAAa,kBAAkB,SAAS;AAAA,YACxC,OAAO,CAAC,IAAI;AAAA,YACZ,YAAY;AAAA,cACR,MAAM,kBAAkB,WAAW;AAAA,YACvC;AAAA,UACJ,CAAC;AAAA,QACL;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../src/modules/auth-guard.ts"],"sourcesContent":["import { buildUnauthorizedGraphqlPayload, buildUnauthorizedPayload } from '@baejino/auth';\nimport type { ErrorRequestHandler, NextFunction, Request, RequestHandler, Response } from 'express';\nimport session from 'express-session';\nimport type { ValidationRule } from 'graphql';\nimport { GraphQLError } from 'graphql';\nimport lusca from 'lusca';\nimport type { AuthConfig } from './auth-mode.js';\nimport { sanitizeRedirectPath } from './auth-redirect.js';\nimport { AUTH_SESSION_IDLE_TIMEOUT_MS, createSessionStore } from './session-store.js';\n\nconst JSON_HEADERS = { 'Content-Type': 'application/json' };\n\nexport const isAuthenticatedRequest = (req: Request) => Boolean(req.session?.authenticated);\n\nexport const createSessionMiddleware = (authConfig: AuthConfig): RequestHandler => {\n if (authConfig.mode !== 'password') {\n return (_req, _res, next) => next();\n }\n\n return session({\n secret: authConfig.sessionSecret,\n name: authConfig.cookieName,\n store: createSessionStore(),\n resave: false,\n saveUninitialized: false,\n rolling: true,\n cookie: {\n maxAge: AUTH_SESSION_IDLE_TIMEOUT_MS,\n httpOnly: true,\n sameSite: 'lax',\n secure: process.env.NODE_ENV === 'production',\n path: '/',\n },\n });\n};\n\nexport const createCsrfProtection = (authConfig: AuthConfig): RequestHandler => {\n if (authConfig.mode !== 'password') {\n return (_req, _res, next) => next();\n }\n\n return lusca.csrf({\n angular: true,\n cookie: {\n options: {\n path: '/',\n sameSite: 'lax',\n secure: process.env.NODE_ENV === 'production',\n },\n },\n });\n};\n\nconst isCsrfTokenError = (error: unknown) => error instanceof Error && error.message.startsWith('CSRF token ');\n\nconst buildLoginRedirectPath = (req: Request) => {\n const nextPath = sanitizeRedirectPath(req.body?.next);\n return `/login?next=${encodeURIComponent(nextPath)}`;\n};\n\nexport const createLoginCsrfFailureHandler = (authConfig: AuthConfig): ErrorRequestHandler => {\n return (error, req, res, next) => {\n if (\n authConfig.mode !== 'password' ||\n !isCsrfTokenError(error) ||\n req.method !== 'POST' ||\n req.path !== '/login' ||\n isAuthenticatedRequest(req)\n ) {\n next(error);\n return;\n }\n\n res.redirect(303, buildLoginRedirectPath(req));\n };\n};\n\nexport const requireSessionForWrite = (authConfig: AuthConfig): RequestHandler => {\n return (req: Request, res: Response, next: NextFunction) => {\n if (authConfig.mode === 'open' || isAuthenticatedRequest(req)) {\n next();\n return;\n }\n\n res.status(401).set(JSON_HEADERS).json(buildUnauthorizedPayload()).end();\n };\n};\n\nexport const requireSessionForGraphql = (authConfig: AuthConfig): RequestHandler => {\n return (req: Request, res: Response, next: NextFunction) => {\n if (authConfig.mode === 'open' || isAuthenticatedRequest(req)) {\n next();\n return;\n }\n\n res.status(401).set(JSON_HEADERS).json(buildUnauthorizedGraphqlPayload()).end();\n };\n};\n\nexport const createMutationAuthValidationRule = (): ValidationRule => {\n return (context) => {\n return {\n OperationDefinition(node) {\n if (node.operation !== 'mutation') {\n return;\n }\n\n const unauthorizedError = buildUnauthorizedGraphqlPayload().errors[0];\n\n context.reportError(\n new GraphQLError(unauthorizedError.message, {\n nodes: [node],\n extensions: {\n code: unauthorizedError.extensions.code,\n },\n }),\n );\n },\n };\n };\n};\n"],"mappings":"AAAA,SAAS,iCAAiC,gCAAgC;AAE1E,OAAO,aAAa;AAEpB,SAAS,oBAAoB;AAC7B,OAAO,WAAW;AAElB,SAAS,4BAA4B;AACrC,SAAS,8BAA8B,0BAA0B;AAEjE,MAAM,eAAe,EAAE,gBAAgB,mBAAmB;AAEnD,MAAM,yBAAyB,CAAC,QAAiB,QAAQ,IAAI,SAAS,aAAa;AAEnF,MAAM,0BAA0B,CAAC,eAA2C;AAC/E,MAAI,WAAW,SAAS,YAAY;AAChC,WAAO,CAAC,MAAM,MAAM,SAAS,KAAK;AAAA,EACtC;AAEA,SAAO,QAAQ;AAAA,IACX,QAAQ,WAAW;AAAA,IACnB,MAAM,WAAW;AAAA,IACjB,OAAO,mBAAmB;AAAA,IAC1B,QAAQ;AAAA,IACR,mBAAmB;AAAA,IACnB,SAAS;AAAA,IACT,QAAQ;AAAA,MACJ,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,UAAU;AAAA,MACV,QAAQ,QAAQ,IAAI,aAAa;AAAA,MACjC,MAAM;AAAA,IACV;AAAA,EACJ,CAAC;AACL;AAEO,MAAM,uBAAuB,CAAC,eAA2C;AAC5E,MAAI,WAAW,SAAS,YAAY;AAChC,WAAO,CAAC,MAAM,MAAM,SAAS,KAAK;AAAA,EACtC;AAEA,SAAO,MAAM,KAAK;AAAA,IACd,SAAS;AAAA,IACT,QAAQ;AAAA,MACJ,SAAS;AAAA,QACL,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQ,QAAQ,IAAI,aAAa;AAAA,MACrC;AAAA,IACJ;AAAA,EACJ,CAAC;AACL;AAEA,MAAM,mBAAmB,CAAC,UAAmB,iBAAiB,SAAS,MAAM,QAAQ,WAAW,aAAa;AAE7G,MAAM,yBAAyB,CAAC,QAAiB;AAC7C,QAAM,WAAW,qBAAqB,IAAI,MAAM,IAAI;AACpD,SAAO,eAAe,mBAAmB,QAAQ,CAAC;AACtD;AAEO,MAAM,gCAAgC,CAAC,eAAgD;AAC1F,SAAO,CAAC,OAAO,KAAK,KAAK,SAAS;AAC9B,QACI,WAAW,SAAS,cACpB,CAAC,iBAAiB,KAAK,KACvB,IAAI,WAAW,UACf,IAAI,SAAS,YACb,uBAAuB,GAAG,GAC5B;AACE,WAAK,KAAK;AACV;AAAA,IACJ;AAEA,QAAI,SAAS,KAAK,uBAAuB,GAAG,CAAC;AAAA,EACjD;AACJ;AAEO,MAAM,yBAAyB,CAAC,eAA2C;AAC9E,SAAO,CAAC,KAAc,KAAe,SAAuB;AACxD,QAAI,WAAW,SAAS,UAAU,uBAAuB,GAAG,GAAG;AAC3D,WAAK;AACL;AAAA,IACJ;AAEA,QAAI,OAAO,GAAG,EAAE,IAAI,YAAY,EAAE,KAAK,yBAAyB,CAAC,EAAE,IAAI;AAAA,EAC3E;AACJ;AAEO,MAAM,2BAA2B,CAAC,eAA2C;AAChF,SAAO,CAAC,KAAc,KAAe,SAAuB;AACxD,QAAI,WAAW,SAAS,UAAU,uBAAuB,GAAG,GAAG;AAC3D,WAAK;AACL;AAAA,IACJ;AAEA,QAAI,OAAO,GAAG,EAAE,IAAI,YAAY,EAAE,KAAK,gCAAgC,CAAC,EAAE,IAAI;AAAA,EAClF;AACJ;AAEO,MAAM,mCAAmC,MAAsB;AAClE,SAAO,CAAC,YAAY;AAChB,WAAO;AAAA,MACH,oBAAoB,MAAM;AACtB,YAAI,KAAK,cAAc,YAAY;AAC/B;AAAA,QACJ;AAEA,cAAM,oBAAoB,gCAAgC,EAAE,OAAO,CAAC;AAEpE,gBAAQ;AAAA,UACJ,IAAI,aAAa,kBAAkB,SAAS;AAAA,YACxC,OAAO,CAAC,IAAI;AAAA,YACZ,YAAY;AAAA,cACR,MAAM,kBAAkB,WAAW;AAAA,YACvC;AAAA,UACJ,CAAC;AAAA,QACL;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { sanitizeRedirectPath as sanitizeCommonRedirectPath } from "@baejino/auth";
2
+ const sanitizeRedirectPath = (value) => sanitizeCommonRedirectPath(value, {
3
+ fallbackPath: "/",
4
+ loginPath: "/login",
5
+ allowedAbsoluteHosts: ["localhost", "127.0.0.1", "::1"]
6
+ });
7
+ export {
8
+ sanitizeRedirectPath
9
+ };
10
+ //# sourceMappingURL=auth-redirect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/modules/auth-redirect.ts"],"sourcesContent":["import { sanitizeRedirectPath as sanitizeCommonRedirectPath } from '@baejino/auth';\n\nexport const sanitizeRedirectPath = (value: unknown) =>\n sanitizeCommonRedirectPath(value, {\n fallbackPath: '/',\n loginPath: '/login',\n allowedAbsoluteHosts: ['localhost', '127.0.0.1', '::1'],\n });\n"],"mappings":"AAAA,SAAS,wBAAwB,kCAAkC;AAE5D,MAAM,uBAAuB,CAAC,UACjC,2BAA2B,OAAO;AAAA,EAC9B,cAAc;AAAA,EACd,WAAW;AAAA,EACX,sBAAsB,CAAC,aAAa,aAAa,KAAK;AAC1D,CAAC;","names":[]}