@cyberismo/backend 0.0.21 → 0.0.23
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.
- package/dist/app.d.ts +5 -2
- package/dist/app.js +25 -10
- package/dist/app.js.map +1 -1
- package/dist/auth/index.d.ts +16 -0
- package/dist/auth/index.js +15 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/keycloak.d.ts +27 -0
- package/dist/auth/keycloak.js +81 -0
- package/dist/auth/keycloak.js.map +1 -0
- package/dist/auth/mock.d.ts +23 -0
- package/dist/auth/mock.js +28 -0
- package/dist/auth/mock.js.map +1 -0
- package/dist/auth/types.d.ts +16 -0
- package/dist/auth/types.js +14 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/domain/auth/index.d.ts +14 -0
- package/dist/domain/auth/index.js +30 -0
- package/dist/domain/auth/index.js.map +1 -0
- package/dist/domain/calculations/index.js +3 -1
- package/dist/domain/calculations/index.js.map +1 -1
- package/dist/domain/calculations/service.js +13 -11
- package/dist/domain/calculations/service.js.map +1 -1
- package/dist/domain/cardTypes/index.js +5 -3
- package/dist/domain/cardTypes/index.js.map +1 -1
- package/dist/domain/cardTypes/service.js +24 -72
- package/dist/domain/cardTypes/service.js.map +1 -1
- package/dist/domain/cards/index.js +124 -25
- package/dist/domain/cards/index.js.map +1 -1
- package/dist/domain/cards/lib.js +92 -93
- package/dist/domain/cards/lib.js.map +1 -1
- package/dist/domain/cards/presence.d.ts +50 -0
- package/dist/domain/cards/presence.js +93 -0
- package/dist/domain/cards/presence.js.map +1 -0
- package/dist/domain/cards/schema.d.ts +47 -0
- package/dist/domain/cards/schema.js +37 -0
- package/dist/domain/cards/schema.js.map +1 -0
- package/dist/domain/cards/service.d.ts +7 -3
- package/dist/domain/cards/service.js +81 -91
- package/dist/domain/cards/service.js.map +1 -1
- package/dist/domain/connectors/index.d.ts +15 -0
- package/dist/domain/connectors/index.js +37 -0
- package/dist/domain/connectors/index.js.map +1 -0
- package/dist/domain/connectors/service.d.ts +23 -0
- package/dist/domain/connectors/service.js +46 -0
- package/dist/domain/connectors/service.js.map +1 -0
- package/dist/domain/fieldTypes/index.js +4 -2
- package/dist/domain/fieldTypes/index.js.map +1 -1
- package/dist/domain/graphModels/index.js +3 -1
- package/dist/domain/graphModels/index.js.map +1 -1
- package/dist/domain/graphViews/index.js +3 -1
- package/dist/domain/graphViews/index.js.map +1 -1
- package/dist/domain/labels/index.js +4 -2
- package/dist/domain/labels/index.js.map +1 -1
- package/dist/domain/labels/service.d.ts +1 -1
- package/dist/domain/labels/service.js +2 -2
- package/dist/domain/labels/service.js.map +1 -1
- package/dist/domain/linkTypes/index.js +4 -2
- package/dist/domain/linkTypes/index.js.map +1 -1
- package/dist/domain/logicPrograms/index.js +3 -1
- package/dist/domain/logicPrograms/index.js.map +1 -1
- package/dist/domain/mcp/index.d.ts +15 -0
- package/dist/domain/mcp/index.js +127 -0
- package/dist/domain/mcp/index.js.map +1 -0
- package/dist/domain/project/index.js +19 -6
- package/dist/domain/project/index.js.map +1 -1
- package/dist/domain/project/schema.d.ts +3 -0
- package/dist/domain/project/schema.js +8 -0
- package/dist/domain/project/schema.js.map +1 -1
- package/dist/domain/project/service.d.ts +3 -1
- package/dist/domain/project/service.js +24 -14
- package/dist/domain/project/service.js.map +1 -1
- package/dist/domain/reports/index.js +3 -1
- package/dist/domain/reports/index.js.map +1 -1
- package/dist/domain/resources/index.js +6 -4
- package/dist/domain/resources/index.js.map +1 -1
- package/dist/domain/resources/service.js +66 -64
- package/dist/domain/resources/service.js.map +1 -1
- package/dist/domain/templates/index.js +5 -3
- package/dist/domain/templates/index.js.map +1 -1
- package/dist/domain/tree/index.js +3 -1
- package/dist/domain/tree/index.js.map +1 -1
- package/dist/domain/tree/service.js +0 -1
- package/dist/domain/tree/service.js.map +1 -1
- package/dist/domain/workflows/index.js +3 -1
- package/dist/domain/workflows/index.js.map +1 -1
- package/dist/export.d.ts +6 -5
- package/dist/export.js +16 -13
- package/dist/export.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/main.js +29 -2
- package/dist/main.js.map +1 -1
- package/dist/middleware/auth.d.ts +40 -0
- package/dist/middleware/auth.js +68 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/commandManager.d.ts +2 -2
- package/dist/middleware/commandManager.js +9 -11
- package/dist/middleware/commandManager.js.map +1 -1
- package/dist/public/THIRD-PARTY.txt +1212 -605
- package/dist/public/assets/index-Cdn_jRWy.js +720 -0
- package/dist/public/assets/index-ypsafPwV.css +1 -0
- package/dist/public/config.json +1 -0
- package/dist/public/images/broken_link.svg +7 -0
- package/dist/public/index.html +2 -2
- package/dist/types.d.ts +25 -0
- package/dist/types.js +13 -1
- package/dist/types.js.map +1 -1
- package/package.json +10 -7
- package/src/app.ts +37 -15
- package/src/auth/index.ts +17 -0
- package/src/auth/keycloak.ts +109 -0
- package/src/auth/mock.ts +38 -0
- package/src/auth/types.ts +18 -0
- package/src/domain/auth/index.ts +35 -0
- package/src/domain/calculations/index.ts +13 -6
- package/src/domain/calculations/service.ts +16 -14
- package/src/domain/cardTypes/index.ts +24 -16
- package/src/domain/cardTypes/service.ts +41 -95
- package/src/domain/cards/index.ts +258 -90
- package/src/domain/cards/lib.ts +102 -100
- package/src/domain/cards/presence.ts +124 -0
- package/src/domain/cards/schema.ts +41 -0
- package/src/domain/cards/service.ts +138 -93
- package/src/domain/connectors/index.ts +39 -0
- package/src/domain/connectors/service.ts +67 -0
- package/src/domain/fieldTypes/index.ts +23 -16
- package/src/domain/graphModels/index.ts +13 -6
- package/src/domain/graphViews/index.ts +13 -6
- package/src/domain/labels/index.ts +5 -2
- package/src/domain/labels/service.ts +2 -2
- package/src/domain/linkTypes/index.ts +14 -7
- package/src/domain/logicPrograms/index.ts +3 -0
- package/src/domain/mcp/index.ts +159 -0
- package/src/domain/project/index.ts +40 -9
- package/src/domain/project/schema.ts +9 -0
- package/src/domain/project/service.ts +37 -17
- package/src/domain/reports/index.ts +13 -6
- package/src/domain/resources/index.ts +6 -1
- package/src/domain/resources/service.ts +102 -97
- package/src/domain/templates/index.ts +31 -19
- package/src/domain/tree/index.ts +3 -1
- package/src/domain/tree/service.ts +0 -1
- package/src/domain/workflows/index.ts +13 -6
- package/src/export.ts +17 -15
- package/src/index.ts +18 -7
- package/src/main.ts +44 -2
- package/src/middleware/auth.ts +90 -0
- package/src/middleware/commandManager.ts +11 -14
- package/src/types.ts +27 -0
- package/dist/public/assets/index-CRSBseQM.css +0 -1
- package/dist/public/assets/index-Ca10XaMv.js +0 -164156
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@media (width<=800px){.breadcrumbs{display:none}}[role=treeitem][aria-selected=false]:hover .treenode{background-color:var(--joy-palette-background-level1,#dedede)}[role=treeitem][aria-selected=true]{outline:none}.resizeHandle{width:2px}.resizeHandle:hover,.resizeHandle:active{background-color:var(--joy-palette-primary-500,#0b6bcb)}.cyberismo-svg-wrapper svg{max-height:100vh}.doc .MuiButton-root{margin-top:12px}.doc table.tableblock{border-collapse:collapse}.doc{color:var(--joy-palette-text-primary,#333);font-size:inherit;-webkit-hyphens:auto;hyphens:auto;margin:0;padding:0;line-height:1.6}@media screen and (width>=1024px){.doc{flex:auto;min-width:0;margin:0;font-size:.94444rem}}.doc h1,.doc h2,.doc h3,.doc h4,.doc h5,.doc h6{color:var(--joy-palette-text-primary,#191919);-webkit-hyphens:none;hyphens:none;margin:1rem 0 0;font-weight:400;line-height:1.3}.doc>h1.page:first-child{margin:1.5rem 0;font-size:2rem}@media screen and (width>=769px){.doc>h1.page:first-child{margin-top:2.5rem}}.doc>h1.page:first-child+aside.toc.embedded{margin-top:-.5rem}.doc>h2#name+.sectionbody{margin-top:1rem}#preamble+.sect1,.doc .sect1+.sect1{margin-top:2rem}.doc h1.sect0{background:var(--joy-palette-background-surface,#f0f0f0);margin:1.5rem -1rem 0;padding:.5rem 1rem;font-size:1.8em}.doc h2:not(.discrete){border-bottom:1px solid var(--joy-palette-divider,#e1e1e1);margin-left:-1rem;margin-right:-1rem;padding:.4rem 1rem .1rem}.doc h3:not(.discrete),.doc h4:not(.discrete){font-weight:600}.doc h1 .anchor,.doc h2 .anchor,.doc h3 .anchor,.doc h4 .anchor,.doc h5 .anchor,.doc h6 .anchor{visibility:hidden;width:1.75ex;margin-left:-1.5ex;padding-top:.05em;font-size:.8em;font-weight:400;text-decoration:none;position:absolute}.doc h1 .anchor:before,.doc h2 .anchor:before,.doc h3 .anchor:before,.doc h4 .anchor:before,.doc h5 .anchor:before,.doc h6 .anchor:before{content:"§"}.doc h1:hover .anchor,.doc h2:hover .anchor,.doc h3:hover .anchor,.doc h4:hover .anchor,.doc h5:hover .anchor,.doc h6:hover .anchor{visibility:visible}.doc dl,.doc p{margin:0}.doc a{color:var(--joy-palette-primary-600,#1565c0)}.doc a:hover{color:var(--joy-palette-primary-700,#104d92)}.doc a.bare{-webkit-hyphens:none;hyphens:none}.doc a.unresolved{color:var(--joy-palette-danger-500,#d32f2f)}.doc i.fa{-webkit-hyphens:none;hyphens:none;font-style:normal}.doc .colist>table code,.doc p code,.doc thead code{color:var(--joy-palette-text-primary,#222);background:var(--joy-palette-background-level1,#fafafa);border-radius:.25em;padding:.125em .25em;font-size:.95em}.doc code,.doc pre{-webkit-hyphens:none;hyphens:none}.doc pre{margin:0;font-size:.88889rem;line-height:1.5}.doc blockquote{margin:0}.doc .paragraph.lead>p{font-size:1rem}.doc .right{float:right}.doc .left{float:left}.doc .float-gap.right{margin:0 1rem 1rem 0}.doc .float-gap.left{margin:0 0 1rem 1rem}.doc .float-group:after{content:"";clear:both;display:table}.doc .text-left{text-align:left}.doc .text-center{text-align:center}.doc .text-right{text-align:right}.doc .text-justify{text-align:justify}.doc .stretch{width:100%}.doc .big{font-size:larger}.doc .small{font-size:smaller}.doc .underline{text-decoration:underline}.doc .line-through{text-decoration:line-through}.doc .dlist,.doc .exampleblock,.doc .hdlist,.doc .imageblock,.doc .listingblock,.doc .literalblock,.doc .olist,.doc .paragraph,.doc .partintro,.doc .quoteblock,.doc .sidebarblock,.doc .tabs,.doc .ulist,.doc .verseblock,.doc .videoblock,.doc details,.doc hr{margin:1rem 0 0}.doc .tablecontainer,.doc .tablecontainer+*,.doc :not(.tablecontainer)>table.tableblock,.doc :not(.tablecontainer)>table.tableblock+*,.doc>table.tableblock,.doc>table.tableblock+*{margin-top:1.5rem}.doc table.tableblock{font-size:.83333rem}.doc p.tableblock+p.tableblock{margin-top:.5rem}.doc table.tableblock pre{font-size:inherit}.doc td.tableblock>.content{word-wrap:anywhere}.doc td.tableblock>.content>:first-child{margin-top:0}.doc table.tableblock td{padding:.5rem}.doc table.tableblock th{background:var(--joy-palette-background-level1,#fbfcfe);padding:.5rem}.doc table.tableblock,.doc table.tableblock>*>tr>*{border:0 solid var(--joy-palette-divider,#e1e1e1)}.doc table.grid-all>*>tr>*{border-width:1px}.doc table.grid-cols>*>tr>*{border-width:0 1px}.doc table.grid-rows>*>tr>*{border-width:1px 0}.doc table.grid-all>thead th,.doc table.grid-rows>thead th{border-bottom-width:2.5px}.doc table.frame-all{border-width:1px}.doc table.frame-ends{border-width:1px 0}.doc table.frame-sides{border-width:0 1px}.doc table.frame-none>colgroup+*>:first-child>*,.doc table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}.doc table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}.doc table.frame-ends>*>tr>:first-child,.doc table.frame-none>*>tr>:first-child{border-left-width:0}.doc table.frame-ends>*>tr>:last-child,.doc table.frame-none>*>tr>:last-child{border-right-width:0}.doc table.stripes-all>tbody>tr,.doc table.stripes-even>tbody>tr:nth-of-type(2n),.doc table.stripes-hover>tbody>tr:hover,.doc table.stripes-odd>tbody>tr:nth-of-type(odd){background:var(--joy-palette-background-level1,#fafafa)}.doc table.tableblock>tfoot{background:var(--joy-palette-background-surface,#f0f0f0)}.doc .halign-left{text-align:left}.doc .halign-right{text-align:right}.doc .halign-center{text-align:center}.doc .valign-top{vertical-align:top}.doc .valign-bottom{vertical-align:bottom}.doc .valign-middle{vertical-align:middle}.doc .admonitionblock{margin:1.4rem 0 0}.doc .admonitionblock p,.doc .admonitionblock td.content{font-size:.88889rem}.doc .admonitionblock td.content>.title+*,.doc .admonitionblock td.content>:not(.title):first-child{margin-top:0}.doc .admonitionblock td.content pre{font-size:.83333rem}.doc .admonitionblock>table{table-layout:fixed;width:100%;position:relative}.doc .admonitionblock td.content{background:var(--joy-palette-background-level1,#fafafa);word-wrap:anywhere;width:100%;padding:1rem 1rem .75rem}.doc .admonitionblock td.icon{padding:0;font-size:.83333rem;line-height:1;position:absolute;top:0;left:0;transform:translate(-.5rem,-50%)}.doc .admonitionblock td.icon i{filter:none;height:1.25rem;vertical-align:initial;border-radius:.45rem;align-items:center;width:fit-content;padding:0 .5rem;display:inline-flex}.doc .admonitionblock td.icon i:after{content:attr(title);text-transform:uppercase;font-style:normal;font-weight:600}.doc .admonitionblock td.icon i.icon-caution{color:#fff;background-color:#a0439c}.doc .admonitionblock td.icon i.icon-important{color:#fff;background-color:#d32f2f}.doc .admonitionblock td.icon i.icon-note{color:#fff;background-color:#217ee7}.doc .admonitionblock td.icon i.icon-tip{color:#fff;background-color:#41af46}.doc .admonitionblock td.icon i.icon-warning{color:#fff;background-color:#e18114}.doc .imageblock,.doc .videoblock{flex-direction:column;align-items:center;display:flex}.doc .imageblock .content{text-align:center;align-self:stretch}.doc .imageblock.text-left,.doc .videoblock.text-left{align-items:flex-start}.doc .imageblock.text-left .content{text-align:left}.doc .imageblock.text-right,.doc .videoblock.text-right{align-items:flex-end}.doc .imageblock.text-right .content{text-align:right}.doc .image>img,.doc .image>object,.doc .image>svg,.doc .imageblock img,.doc .imageblock object,.doc .imageblock svg{vertical-align:middle;max-width:100%;max-height:75vh;display:inline-block}.doc .image:not(.left):not(.right)>img{margin-top:-.2em}.doc .videoblock iframe,.doc .videoblock video{vertical-align:middle;max-width:100%}#preamble .abstract blockquote{background:var(--joy-palette-background-surface,#f0f0f0);border-left:5px solid var(--joy-palette-divider,#e1e1e1);color:var(--joy-palette-text-secondary,#4a4a4a);padding:.75em 1em;font-size:.88889rem}.doc .quoteblock,.doc .verseblock{background:var(--joy-palette-background-level1,#fafafa);border-left:5px solid var(--joy-palette-neutral-500,#5d5d5d);color:var(--joy-palette-text-secondary,#5d5d5d)}.doc .quoteblock{padding:.25rem 2rem 1.25rem}.doc .quoteblock .attribution{color:var(--joy-palette-text-tertiary,#8e8e8e);margin-top:.75rem;font-size:.83333rem}.doc .quoteblock blockquote{margin-top:1rem}.doc .quoteblock .paragraph{font-style:italic}.doc .quoteblock cite{padding-left:1em}.doc .verseblock{padding:1rem 2rem;font-size:1.15em}.doc .verseblock pre{font-family:inherit;font-size:inherit}.doc ol,.doc ul{margin:0;padding:0 0 0 2rem}.doc ol.none,.doc ol.unnumbered,.doc ol.unstyled,.doc ul.checklist,.doc ul.no-bullet,.doc ul.none,.doc ul.unstyled{list-style-type:none}.doc ol.unnumbered,.doc ul.no-bullet{padding-left:1.25rem}.doc ol.unstyled,.doc ul.unstyled{padding-left:0}.doc ul.circle{list-style-type:circle}.doc ul.disc{list-style-type:disc}.doc ul.square{list-style-type:square}.doc ul.circle ul:not([class]),.doc ul.disc ul:not([class]),.doc ul.square ul:not([class]){list-style:inherit}.doc ol.arabic{list-style-type:decimal}.doc ol.decimal{list-style-type:decimal-leading-zero}.doc ol.loweralpha{list-style-type:lower-alpha}.doc ol.upperalpha{list-style-type:upper-alpha}.doc ol.lowerroman{list-style-type:lower-roman}.doc ol.upperroman{list-style-type:upper-roman}.doc ol.lowergreek{list-style-type:lower-greek}.doc ul.checklist{padding-left:1.75rem}.doc .dlist .dlist,.doc .dlist .olist,.doc .dlist .ulist,.doc .olist .dlist,.doc .olist .olist,.doc .olist .ulist,.doc .olist li+li,.doc .ulist .dlist,.doc .ulist .olist,.doc .ulist .ulist,.doc .ulist li+li{margin-top:.5rem}.doc .admonitionblock .listingblock,.doc .olist .listingblock,.doc .ulist .listingblock{padding:0}.doc .admonitionblock .title,.doc .exampleblock .title,.doc .imageblock .title,.doc .listingblock .title,.doc .literalblock .title,.doc .openblock .title,.doc .videoblock .title,.doc table.tableblock caption{color:var(--joy-palette-text-secondary,#5d5d5d);-webkit-hyphens:none;hyphens:none;letter-spacing:.01em;padding-bottom:.075rem;font-size:.88889rem;font-style:italic;font-weight:600}.doc table.tableblock caption{text-align:left}.doc .olist .title,.doc .ulist .title{margin-bottom:.25rem;font-style:italic;font-weight:600}.doc .imageblock .title,.doc .videoblock .title{margin-top:.5rem;padding-bottom:0}.doc details{margin-left:1rem}.doc details>summary{margin-bottom:.5rem;line-height:1.6;display:block;position:relative}.doc details>summary::-webkit-details-marker{display:none}.doc details>summary:before{content:"";border:.3em solid #0000;border-left:.5em solid;border-right-width:0;position:absolute;top:.5em;left:-1rem;transform:translate(15%)}.doc details[open]>summary:before{border-width:.5rem .3rem 0;border-color:currentColor #0000 #0000;transform:translateY(15%)}.doc details>summary:after{content:"";width:1rem;height:1em;position:absolute;top:.3em;left:-1rem}.doc details.result{margin-top:.25rem}.doc details.result>summary{color:var(--joy-palette-text-secondary,#5d5d5d);margin-bottom:0;font-style:italic}.doc details.result>.content{margin-left:-1rem}.doc .exampleblock>.content,.doc details.result>.content{background:var(--joy-palette-background-body,#fff);border:.25rem solid var(--joy-palette-neutral-500,#5d5d5d);border-radius:.5rem;padding:.75rem}.doc .exampleblock>.content:after,.doc details.result>.content:after{content:"";clear:both;display:table}.doc .exampleblock>.content>:first-child,.doc details>.content>:first-child{margin-top:0}.doc .sidebarblock{background:var(--joy-palette-neutral-softBg,#e1e1e1);border-radius:.75rem;padding:.75rem 1.5rem}.doc .sidebarblock>.content>.title{text-align:center;margin-bottom:.5rem;font-size:1.25rem;font-weight:600;line-height:1.3}.doc .sidebarblock>.content>.title+*,.doc .sidebarblock>.content>:not(.title):first-child{margin-top:0}.doc .listingblock.wrap pre,.doc table.tableblock pre{white-space:pre-wrap}.doc .listingblock pre:not(.highlight),.doc .literalblock pre,.doc pre.highlight>code{background:var(--joy-palette-background-level1,#fafafa);-webkit-box-shadow:inset 0 0 1.75px var(--joy-palette-divider,#e1e1e1);box-shadow:inset 0 0 1.75px var(--joy-palette-divider,#e1e1e1);padding:.875em;display:block;overflow-x:auto}.doc .listingblock>.content{position:relative}.doc .source-toolbox{visibility:hidden;color:gray;-webkit-user-select:none;user-select:none;white-space:nowrap;z-index:1;font-family:Roboto,sans-serif;font-size:.72222rem;line-height:1;display:flex;position:absolute;top:.25rem;right:.5rem}.doc .listingblock:hover .source-toolbox{visibility:visible}.doc .source-toolbox .source-lang{text-transform:uppercase;letter-spacing:.075em}.doc .source-toolbox>:not(:last-child):after{content:"|";letter-spacing:0;padding:0 1ch}.doc .source-toolbox .copy-button{color:inherit;font-size:inherit;line-height:inherit;background:0 0;border:none;outline:none;flex-direction:column;align-items:center;width:1em;height:1em;padding:0;display:flex}.doc .source-toolbox .copy-icon{width:inherit;height:inherit;flex:none}.doc .source-toolbox img.copy-icon{filter:invert(50.2%)}.doc .source-toolbox svg.copy-icon{fill:currentColor}.doc .source-toolbox .copy-toast{background-color:var(--joy-palette-neutral-800,#333);color:var(--joy-palette-common-white,#fff);cursor:auto;opacity:0;border-radius:.25em;flex:none;justify-content:center;margin-top:1em;padding:.5em;transition:opacity .5s .5s;display:inline-flex;position:relative}.doc .source-toolbox .copy-toast:after{content:"";border:.55em solid #0000;border-left-color:var(--joy-palette-neutral-800,#333);transform-origin:0;width:1em;height:1em;position:absolute;top:0;transform:rotate(-90deg)translate(50%)translateY(50%)}.doc .source-toolbox .copy-button.clicked .copy-toast{opacity:1;transition:none}.doc .language-console .hljs-meta{-webkit-user-select:none;user-select:none}.doc .dlist dt{font-style:italic}.doc .dlist dd{margin:0 0 0 1.5rem}.doc .dlist dd+dt,.doc .dlist dd>p:first-child{margin-top:.5rem}.doc td.hdlist1,.doc td.hdlist2{vertical-align:top;padding:.5rem 0 0}.doc tr:first-child>.hdlist1,.doc tr:first-child>.hdlist2{padding-top:0}.doc td.hdlist1{padding-right:.25rem;font-weight:600}.doc td.hdlist2{padding-left:.25rem}.doc .colist{margin:.25rem 0 -.25rem;font-size:.88889rem}.doc .colist>table>tbody>tr>:first-child,.doc .colist>table>tr>:first-child{vertical-align:top;padding:.25em .5rem 0}.doc .colist>table>tbody>tr>:last-child,.doc .colist>table>tr>:last-child{padding:.25rem 0}.doc .conum[data-value]{text-align:center;letter-spacing:-.25ex;text-indent:-.25ex;border:1px solid;border-radius:100%;width:1.25em;height:1.25em;font-family:Roboto,sans-serif;font-size:.75rem;font-style:normal;line-height:1.2;display:inline-block}.doc .conum[data-value]:after{content:attr(data-value)}.doc .conum[data-value]+b{display:none}.doc hr{border:solid var(--joy-palette-divider,#e1e1e1);border-width:2px 0 0;height:0}.doc b.button{white-space:nowrap}.doc b.button:before{content:"[";padding-right:.25em}.doc b.button:after{content:"]";padding-left:.25em}.doc kbd{background:var(--joy-palette-background-level1,#fafafa);border:1px solid var(--joy-palette-neutral-400,#c1c1c1);-webkit-box-shadow:0 1px 0 var(--joy-palette-neutral-400,#c1c1c1), 0 0 0 .1em var(--joy-palette-background-body,#fff) inset;box-shadow:0 1px 0 var(--joy-palette-neutral-400,#c1c1c1), inset 0 0 0 .1em var(--joy-palette-background-body,#fff);vertical-align:text-bottom;white-space:nowrap;border-radius:.25em;padding:.25em .5em;font-size:.66667rem;display:inline-block}.doc .keyseq,.doc kbd{line-height:1}.doc .keyseq{font-size:.88889rem}.doc .keyseq kbd{margin:0 .125em}.doc .keyseq kbd:first-child{margin-left:0}.doc .keyseq kbd:last-child{margin-right:0}.doc .menuseq,.doc .path{-webkit-hyphens:none;hyphens:none}.doc .menuseq i.caret:before{content:"›";font-size:1.1em;font-weight:600;line-height:.90909}.doc :not(pre).nowrap{white-space:nowrap}.doc .nobreak{-webkit-hyphens:none;hyphens:none;word-wrap:normal}.doc :not(pre).pre-wrap{white-space:pre-wrap}#footnotes{margin:2rem -.5rem 0;font-size:.85em;line-height:1.5}.doc td.tableblock>.content #footnotes{margin:2rem 0 0}#footnotes hr{border-top-width:1px;width:20%;margin-top:0}#footnotes .footnote{margin:.5em 0 0 1em}#footnotes .footnote+.footnote{margin-top:.25em}#footnotes .footnote>a:first-of-type{text-align:right;width:1.5em;margin-left:-2em;display:inline-block}.toc-menu{color:var(--joy-palette-text-secondary,#5d5d5d)}.toc.sidebar .toc-menu{margin-right:.75rem;position:sticky;top:6rem}.toc .toc-menu h3{color:var(--joy-palette-text-primary,#333);margin:0 -.5px;padding-bottom:.25rem;font-size:.88889rem;font-weight:600;line-height:1.3}.toc.sidebar .toc-menu h3{flex-direction:column;justify-content:flex-end;height:2.5rem;display:flex}.toc .toc-menu ul{margin:0;padding:0;font-size:.83333rem;line-height:1.2;list-style:none}.toc.sidebar .toc-menu ul{-ms-scroll-chaining:none;overscroll-behavior:none;max-height:calc(100vh - 8.5rem);overflow-y:auto}@supports (scrollbar-width:none){.toc.sidebar .toc-menu ul{scrollbar-width:none}}.toc .toc-menu ul::-webkit-scrollbar{width:0;height:0}@media screen and (width>=1024px){.toc .toc-menu h3{font-size:.83333rem}.toc .toc-menu ul{font-size:.75rem}}.toc .toc-menu li{margin:0}.toc .toc-menu li[data-level="2"] a{padding-left:1.25rem}.toc .toc-menu li[data-level="3"] a{padding-left:2rem}.toc .toc-menu a{color:inherit;border-left:2px solid var(--joy-palette-divider,#e1e1e1);padding:.25rem 0 .25rem .5rem;text-decoration:none;display:inline-block}.sidebar.toc .toc-menu a{outline:none;display:block}.toc .toc-menu a:hover{color:var(--joy-palette-primary-600,#1565c0)}.toc .toc-menu a.is-active{border-left-color:var(--joy-palette-primary-500,#2a7ee4);color:var(--joy-palette-primary-500,#2a7ee4)}.sidebar.toc .toc-menu a:focus{background:var(--joy-palette-background-level1,#fafafa)}.toc .toc-menu .is-hidden-toc{display:none!important}.contentSidebar{min-width:160px}.doc .videoblock .content{width:100%;max-width:100%;position:relative}.doc .videoblock .content:before{content:"";padding-top:56.25%;display:block}.doc .videoblock .content>iframe,.doc .videoblock .content>video{background:#000;border:0;display:block;position:absolute;inset:0;width:100%!important;height:100%!important}
|
package/dist/public/config.json
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg width="721" height="283" viewBox="0 0 721 283" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M163 140.5C163 176.122 191.878 205 227.5 205L255.5 205L226.5 235L227.5 235C175.309 235 133 192.691 133 140.5C133 88.3091 175.309 46 227.5 46L427.5 46L397.5 76L227.5 76C191.878 76 163 104.878 163 140.5Z" fill="black"/>
|
|
3
|
+
<path d="M566.5 140.5C566.5 104.878 537.622 76 502 76L474 76L503 46L502 46C554.191 46 596.5 88.3091 596.5 140.5C596.5 192.691 554.191 235 502 235L365 235L392 205L502 205C537.622 205 566.5 176.122 566.5 140.5Z" fill="black"/>
|
|
4
|
+
<path d="M366.012 98.4991L224.882 266.38L340.776 171.162L348.984 212.415L504.678 0.000272155L398.529 107.516L366.012 98.4991Z" fill="#FF4400"/>
|
|
5
|
+
<rect x="456" y="123" width="265" height="35" rx="17.5" fill="black"/>
|
|
6
|
+
<rect y="123" width="265" height="35" rx="17.5" fill="black"/>
|
|
7
|
+
</svg>
|
package/dist/public/index.html
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
name="msapplication-TileImage"
|
|
12
12
|
content="/cropped-favicon-270x270.png"
|
|
13
13
|
/>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
15
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-Cdn_jRWy.js"></script>
|
|
15
|
+
<link rel="stylesheet" crossorigin href="/assets/index-ypsafPwV.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
|
18
18
|
<div id="root"></div>
|
package/dist/types.d.ts
CHANGED
|
@@ -21,8 +21,33 @@ export interface TreeOptions {
|
|
|
21
21
|
recursive?: boolean;
|
|
22
22
|
cardKey?: string;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* User roles - checked directly in middleware
|
|
26
|
+
* Role hierarchy: Admin > Editor > Reader
|
|
27
|
+
* - Admin: All operations including configuration
|
|
28
|
+
* - Editor: Can create, edit, and manage content but not config
|
|
29
|
+
* - Reader: Can only view content
|
|
30
|
+
*/
|
|
31
|
+
export declare enum UserRole {
|
|
32
|
+
Admin = "admin",
|
|
33
|
+
Editor = "editor",
|
|
34
|
+
Reader = "reader"
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* User information returned by the /me endpoint
|
|
38
|
+
*/
|
|
39
|
+
export interface UserInfo {
|
|
40
|
+
id: string;
|
|
41
|
+
email: string;
|
|
42
|
+
name: string;
|
|
43
|
+
role: UserRole;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Extended app variables including authentication info
|
|
47
|
+
*/
|
|
24
48
|
export interface AppVars {
|
|
25
49
|
tree?: TreeOptions;
|
|
50
|
+
user?: UserInfo;
|
|
26
51
|
}
|
|
27
52
|
export type AppContext = Context<{
|
|
28
53
|
Variables: AppVars;
|
package/dist/types.js
CHANGED
|
@@ -10,5 +10,17 @@
|
|
|
10
10
|
details. You should have received a copy of the GNU Affero General Public
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* User roles - checked directly in middleware
|
|
15
|
+
* Role hierarchy: Admin > Editor > Reader
|
|
16
|
+
* - Admin: All operations including configuration
|
|
17
|
+
* - Editor: Can create, edit, and manage content but not config
|
|
18
|
+
* - Reader: Can only view content
|
|
19
|
+
*/
|
|
20
|
+
export var UserRole;
|
|
21
|
+
(function (UserRole) {
|
|
22
|
+
UserRole["Admin"] = "admin";
|
|
23
|
+
UserRole["Editor"] = "editor";
|
|
24
|
+
UserRole["Reader"] = "reader";
|
|
25
|
+
})(UserRole || (UserRole = {}));
|
|
14
26
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAiBF;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;AACnB,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberismo/backend",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "Express backend for Cyberismo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -14,14 +14,17 @@
|
|
|
14
14
|
"bugs": "https://github.com/CyberismoCom/cyberismo/issues",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@asciidoctor/core": "^3.0.4",
|
|
17
|
-
"@
|
|
17
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
18
|
+
"@hono/node-server": "^1.19.10",
|
|
18
19
|
"@hono/zod-validator": "^0.7.6",
|
|
19
20
|
"@types/mime-types": "^3.0.1",
|
|
20
|
-
"dotenv": "^17.
|
|
21
|
-
"hono": "^4.
|
|
21
|
+
"dotenv": "^17.3.1",
|
|
22
|
+
"hono": "^4.12.7",
|
|
23
|
+
"jose": "^6.1.3",
|
|
22
24
|
"mime-types": "^3.0.2",
|
|
23
25
|
"zod": "^4.3.6",
|
|
24
|
-
"@cyberismo/
|
|
26
|
+
"@cyberismo/mcp": "0.0.23",
|
|
27
|
+
"@cyberismo/data-handler": "0.0.23"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
30
|
"@cyberismo/app": "0.0.2"
|
|
@@ -37,8 +40,8 @@
|
|
|
37
40
|
],
|
|
38
41
|
"scripts": {
|
|
39
42
|
"start": "tsx src/main.ts",
|
|
40
|
-
"start-e2e": "node dist/main.js",
|
|
41
|
-
"dev": "tsx watch src/main.ts",
|
|
43
|
+
"start-e2e": "cross-env AUTH_MODE=mock node dist/main.js",
|
|
44
|
+
"dev": "cross-env AUTH_MODE=mock tsx watch src/main.ts",
|
|
42
45
|
"debug": "tsx --inspect-brk src/main.ts",
|
|
43
46
|
"export": "pnpm build && node dist/main.js --export",
|
|
44
47
|
"build": "tsc -p tsconfig.build.json && shx rm -rf ./dist/public && shx cp -r ../app/dist ./dist/public",
|
package/src/app.ts
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { Hono } from 'hono';
|
|
14
14
|
import { staticFrontendDirRelative } from './utils.js';
|
|
15
|
-
import { cors } from 'hono/cors';
|
|
16
15
|
import { serveStatic } from '@hono/node-server/serve-static';
|
|
17
16
|
import { attachCommandManager } from './middleware/commandManager.js';
|
|
18
17
|
import calculationsRouter from './domain/calculations/index.js';
|
|
19
18
|
import cardsRouter from './domain/cards/index.js';
|
|
20
19
|
import cardTypesRouter from './domain/cardTypes/index.js';
|
|
20
|
+
import connectorsRouter from './domain/connectors/index.js';
|
|
21
21
|
import fieldTypesRouter from './domain/fieldTypes/index.js';
|
|
22
22
|
import graphModelsRouter from './domain/graphModels/index.js';
|
|
23
23
|
import graphViewsRouter from './domain/graphViews/index.js';
|
|
@@ -32,34 +32,46 @@ import path from 'node:path';
|
|
|
32
32
|
import resourcesRouter from './domain/resources/index.js';
|
|
33
33
|
import logicProgramsRouter from './domain/logicPrograms/index.js';
|
|
34
34
|
import { isSSGContext } from 'hono/ssg';
|
|
35
|
+
import type { CommandManager } from '@cyberismo/data-handler';
|
|
35
36
|
import type { AppVars, TreeOptions } from './types.js';
|
|
36
37
|
import treeMiddleware from './middleware/tree.js';
|
|
37
38
|
import projectRouter from './domain/project/index.js';
|
|
39
|
+
import mcpRouter from './domain/mcp/index.js';
|
|
40
|
+
import { createAuthRouter } from './domain/auth/index.js';
|
|
41
|
+
import { createAuthMiddleware } from './middleware/auth.js';
|
|
42
|
+
import type { AuthProvider } from './auth/types.js';
|
|
38
43
|
|
|
39
44
|
/**
|
|
40
45
|
* Create the Hono app for the backend
|
|
41
|
-
* @param
|
|
46
|
+
* @param authProvider - Authentication provider
|
|
47
|
+
* @param commands - CommandManager instance for the project
|
|
42
48
|
*/
|
|
43
|
-
export function createApp(
|
|
49
|
+
export function createApp(
|
|
50
|
+
authProvider: AuthProvider,
|
|
51
|
+
commands: CommandManager,
|
|
52
|
+
opts?: TreeOptions,
|
|
53
|
+
) {
|
|
44
54
|
const app = new Hono<{ Variables: AppVars }>();
|
|
45
55
|
|
|
46
|
-
app.use('/api', cors());
|
|
47
|
-
|
|
48
|
-
app.use(
|
|
49
|
-
'*',
|
|
50
|
-
serveStatic({
|
|
51
|
-
root: staticFrontendDirRelative,
|
|
52
|
-
}),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
56
|
app.use(treeMiddleware(opts));
|
|
56
|
-
//
|
|
57
|
-
app.use(
|
|
57
|
+
// Apply authentication middleware to all API and MCP routes
|
|
58
|
+
app.use('/api/*', createAuthMiddleware(authProvider));
|
|
59
|
+
app.use('/mcp', createAuthMiddleware(authProvider));
|
|
60
|
+
app.use('/mcp/*', createAuthMiddleware(authProvider));
|
|
58
61
|
|
|
62
|
+
// Attach CommandManager to API and MCP routes
|
|
63
|
+
const commandManagerMiddleware = attachCommandManager(commands);
|
|
64
|
+
app.use('/api/*', commandManagerMiddleware);
|
|
65
|
+
app.use('/mcp', commandManagerMiddleware);
|
|
66
|
+
app.use('/mcp/*', commandManagerMiddleware);
|
|
59
67
|
// Wire up routes
|
|
68
|
+
app.route('/api/auth', createAuthRouter());
|
|
69
|
+
|
|
70
|
+
// Mount routers
|
|
60
71
|
app.route('/api/calculations', calculationsRouter);
|
|
61
72
|
app.route('/api/cards', cardsRouter);
|
|
62
73
|
app.route('/api/cardTypes', cardTypesRouter);
|
|
74
|
+
app.route('/api/connectors', connectorsRouter);
|
|
63
75
|
app.route('/api/fieldTypes', fieldTypesRouter);
|
|
64
76
|
app.route('/api/graphModels', graphModelsRouter);
|
|
65
77
|
app.route('/api/graphViews', graphViewsRouter);
|
|
@@ -73,10 +85,20 @@ export function createApp(projectPath?: string, opts?: TreeOptions) {
|
|
|
73
85
|
app.route('/api/labels', labelsRouter);
|
|
74
86
|
app.route('/api/project', projectRouter);
|
|
75
87
|
|
|
88
|
+
// MCP endpoint for AI assistant integration
|
|
89
|
+
app.route('/mcp', mcpRouter);
|
|
90
|
+
|
|
91
|
+
app.use(
|
|
92
|
+
'*',
|
|
93
|
+
serveStatic({
|
|
94
|
+
root: staticFrontendDirRelative,
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
|
|
76
98
|
// serve index.html for all other routes
|
|
77
99
|
app.notFound(async (c) => {
|
|
78
100
|
if (c.req.path.startsWith('/api')) {
|
|
79
|
-
return c.text('Not Found',
|
|
101
|
+
return c.text('Not Found', 404);
|
|
80
102
|
}
|
|
81
103
|
const file = await readFile(
|
|
82
104
|
path.join(import.meta.dirname, 'public', 'index.html'),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2026
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation. This program is distributed in the hope that it
|
|
7
|
+
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
8
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
See the GNU Affero General Public License for more details.
|
|
10
|
+
You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export type { AuthProvider } from './types.js';
|
|
15
|
+
export { MockAuthProvider } from './mock.js';
|
|
16
|
+
export { KeycloakAuthProvider } from './keycloak.js';
|
|
17
|
+
export type { KeycloakConfig } from './keycloak.js';
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2026
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation. This program is distributed in the hope that it
|
|
7
|
+
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
8
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
See the GNU Affero General Public License for more details.
|
|
10
|
+
You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { createRemoteJWKSet, jwtVerify } from 'jose';
|
|
15
|
+
import type { JWTPayload } from 'jose';
|
|
16
|
+
import { UserRole } from '../types.js';
|
|
17
|
+
import type { UserInfo } from '../types.js';
|
|
18
|
+
import type { AuthProvider } from './types.js';
|
|
19
|
+
|
|
20
|
+
export interface KeycloakConfig {
|
|
21
|
+
issuer: string;
|
|
22
|
+
audience: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface KeycloakJWTPayload extends JWTPayload {
|
|
26
|
+
email?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
preferred_username?: string;
|
|
29
|
+
realm_access?: {
|
|
30
|
+
roles?: string[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class KeycloakAuthProvider implements AuthProvider {
|
|
35
|
+
private readonly issuer: string;
|
|
36
|
+
private readonly audience: string;
|
|
37
|
+
private jwks: ReturnType<typeof createRemoteJWKSet> | null = null;
|
|
38
|
+
|
|
39
|
+
constructor(config: KeycloakConfig) {
|
|
40
|
+
this.issuer = config.issuer;
|
|
41
|
+
this.audience = config.audience;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private getJWKS(): ReturnType<typeof createRemoteJWKSet> {
|
|
45
|
+
if (!this.jwks) {
|
|
46
|
+
const jwksUrl = new URL(
|
|
47
|
+
`${this.issuer.replace(/\/$/, '')}/protocol/openid-connect/certs`,
|
|
48
|
+
);
|
|
49
|
+
this.jwks = createRemoteJWKSet(jwksUrl);
|
|
50
|
+
}
|
|
51
|
+
return this.jwks;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async authenticate(req: Request): Promise<UserInfo | null> {
|
|
55
|
+
const authHeader = req.headers.get('authorization');
|
|
56
|
+
if (!authHeader) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const token = authHeader.replace(/^Bearer\s+/i, '');
|
|
61
|
+
if (!token) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const jwks = this.getJWKS();
|
|
67
|
+
const { payload } = await jwtVerify(token, jwks, {
|
|
68
|
+
issuer: this.issuer,
|
|
69
|
+
audience: this.audience,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const claims = payload as KeycloakJWTPayload;
|
|
73
|
+
const role = this.mapRole(claims.realm_access?.roles);
|
|
74
|
+
|
|
75
|
+
if (!claims.sub) {
|
|
76
|
+
throw new Error('Missing sub');
|
|
77
|
+
}
|
|
78
|
+
if (!claims.email) {
|
|
79
|
+
throw new Error('Missing email');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
id: claims.sub,
|
|
84
|
+
email: claims.email,
|
|
85
|
+
name: claims.name ?? claims.preferred_username ?? 'Unknown',
|
|
86
|
+
role,
|
|
87
|
+
};
|
|
88
|
+
} catch {
|
|
89
|
+
// TODO: add proper logging
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private mapRole(roles?: string[]): UserRole {
|
|
95
|
+
if (!roles) {
|
|
96
|
+
throw new Error('Token missing realm_access roles');
|
|
97
|
+
}
|
|
98
|
+
if (roles.includes('admin')) {
|
|
99
|
+
return UserRole.Admin;
|
|
100
|
+
}
|
|
101
|
+
if (roles.includes('editor')) {
|
|
102
|
+
return UserRole.Editor;
|
|
103
|
+
}
|
|
104
|
+
if (roles.includes('reader')) {
|
|
105
|
+
return UserRole.Reader;
|
|
106
|
+
}
|
|
107
|
+
throw new Error('No recognized role found in token');
|
|
108
|
+
}
|
|
109
|
+
}
|
package/src/auth/mock.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2026
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation. This program is distributed in the hope that it
|
|
7
|
+
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
8
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
See the GNU Affero General Public License for more details.
|
|
10
|
+
You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { UserRole } from '../types.js';
|
|
15
|
+
import type { UserInfo } from '../types.js';
|
|
16
|
+
import type { AuthProvider } from './types.js';
|
|
17
|
+
|
|
18
|
+
export interface MockUserConfig {
|
|
19
|
+
name?: string;
|
|
20
|
+
email?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class MockAuthProvider implements AuthProvider {
|
|
24
|
+
private readonly userConfig: MockUserConfig;
|
|
25
|
+
|
|
26
|
+
constructor(config?: MockUserConfig) {
|
|
27
|
+
this.userConfig = config ?? {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async authenticate(): Promise<UserInfo> {
|
|
31
|
+
return {
|
|
32
|
+
id: 'mock-user',
|
|
33
|
+
email: this.userConfig.email ?? 'admin@cyberismo.local',
|
|
34
|
+
name: this.userConfig.name ?? 'Local Admin',
|
|
35
|
+
role: UserRole.Admin,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2026
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation. This program is distributed in the hope that it
|
|
7
|
+
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
8
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
See the GNU Affero General Public License for more details.
|
|
10
|
+
You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { UserInfo } from '../types.js';
|
|
15
|
+
|
|
16
|
+
export interface AuthProvider {
|
|
17
|
+
authenticate(req: Request): Promise<UserInfo | null>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2026
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation. This program is distributed in the hope that it
|
|
7
|
+
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
8
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
See the GNU Affero General Public License for more details.
|
|
10
|
+
You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { Hono } from 'hono';
|
|
15
|
+
import { getCurrentUser } from '../../middleware/auth.js';
|
|
16
|
+
|
|
17
|
+
export function createAuthRouter() {
|
|
18
|
+
const router = new Hono();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* GET /api/auth/me
|
|
22
|
+
* Returns the current user's information (id, email, name, role)
|
|
23
|
+
*/
|
|
24
|
+
router.get('/me', async (c) => {
|
|
25
|
+
const user = getCurrentUser(c);
|
|
26
|
+
|
|
27
|
+
if (!user) {
|
|
28
|
+
return c.json({ error: 'Unauthorized' }, 401);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return c.json(user);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return router;
|
|
35
|
+
}
|
|
@@ -15,6 +15,8 @@ import { Hono } from 'hono';
|
|
|
15
15
|
import * as calculationService from './service.js';
|
|
16
16
|
import { createCalculationSchema } from './schema.js';
|
|
17
17
|
import { zValidator } from '../../middleware/zvalidator.js';
|
|
18
|
+
import { UserRole } from '../../types.js';
|
|
19
|
+
import { requireRole } from '../../middleware/auth.js';
|
|
18
20
|
|
|
19
21
|
const router = new Hono();
|
|
20
22
|
|
|
@@ -43,12 +45,17 @@ const router = new Hono();
|
|
|
43
45
|
* 500:
|
|
44
46
|
* description: Server error
|
|
45
47
|
*/
|
|
46
|
-
router.post(
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
router.post(
|
|
49
|
+
'/',
|
|
50
|
+
requireRole(UserRole.Admin),
|
|
51
|
+
zValidator('json', createCalculationSchema),
|
|
52
|
+
async (c) => {
|
|
53
|
+
const commands = c.get('commands');
|
|
54
|
+
const { identifier } = c.req.valid('json');
|
|
49
55
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
56
|
+
await calculationService.createCalculation(commands, identifier);
|
|
57
|
+
return c.json({ message: 'Calculation created successfully' });
|
|
58
|
+
},
|
|
59
|
+
);
|
|
53
60
|
|
|
54
61
|
export default router;
|
|
@@ -26,20 +26,22 @@ export async function createCalculation(
|
|
|
26
26
|
commands: CommandManager,
|
|
27
27
|
identifier: string,
|
|
28
28
|
) {
|
|
29
|
-
await commands.
|
|
29
|
+
await commands.atomic(async () => {
|
|
30
|
+
await commands.createCmd.createCalculation(identifier);
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
// Set displayName to capitalized version of identifier
|
|
33
|
+
const project = await commands.showCmd.showProject();
|
|
34
|
+
await updateResourceWithOperation(
|
|
35
|
+
commands,
|
|
36
|
+
{ prefix: project.prefix, type: 'calculations', identifier },
|
|
37
|
+
{
|
|
38
|
+
updateKey: { key: 'displayName' },
|
|
39
|
+
operation: {
|
|
40
|
+
name: 'change',
|
|
41
|
+
target: '',
|
|
42
|
+
to: capitalize(identifier),
|
|
43
|
+
},
|
|
42
44
|
},
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
+
);
|
|
46
|
+
}, `Create calculation ${identifier}`);
|
|
45
47
|
}
|
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
fieldVisibilityBodySchema,
|
|
20
20
|
} from './schema.js';
|
|
21
21
|
import { zValidator } from '../../middleware/zvalidator.js';
|
|
22
|
+
import { UserRole } from '../../types.js';
|
|
23
|
+
import { requireRole } from '../../middleware/auth.js';
|
|
22
24
|
|
|
23
25
|
const router = new Hono();
|
|
24
26
|
|
|
@@ -36,7 +38,7 @@ const router = new Hono();
|
|
|
36
38
|
* 500:
|
|
37
39
|
* description: project_path not set or other internal error
|
|
38
40
|
*/
|
|
39
|
-
router.get('/', async (c) => {
|
|
41
|
+
router.get('/', requireRole(UserRole.Reader), async (c) => {
|
|
40
42
|
const commands = c.get('commands');
|
|
41
43
|
|
|
42
44
|
try {
|
|
@@ -80,22 +82,27 @@ router.get('/', async (c) => {
|
|
|
80
82
|
* 500:
|
|
81
83
|
* description: Server error
|
|
82
84
|
*/
|
|
83
|
-
router.post(
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
router.post(
|
|
86
|
+
'/',
|
|
87
|
+
requireRole(UserRole.Admin),
|
|
88
|
+
zValidator('json', createCardTypeSchema),
|
|
89
|
+
async (c) => {
|
|
90
|
+
const commands = c.get('commands');
|
|
91
|
+
const { identifier, workflowName } = c.req.valid('json');
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
93
|
+
try {
|
|
94
|
+
await cardTypeService.createCardType(commands, identifier, workflowName);
|
|
95
|
+
return c.json({ message: 'Card type created successfully' });
|
|
96
|
+
} catch (error) {
|
|
97
|
+
return c.json(
|
|
98
|
+
{
|
|
99
|
+
error: `${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
100
|
+
},
|
|
101
|
+
500,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
);
|
|
99
106
|
|
|
100
107
|
/**
|
|
101
108
|
* @swagger
|
|
@@ -142,6 +149,7 @@ router.post('/', zValidator('json', createCardTypeSchema), async (c) => {
|
|
|
142
149
|
*/
|
|
143
150
|
router.patch(
|
|
144
151
|
'/:cardTypeName/field-visibility',
|
|
152
|
+
requireRole(UserRole.Admin),
|
|
145
153
|
zValidator('param', cardTypeNameParamSchema),
|
|
146
154
|
zValidator('json', fieldVisibilityBodySchema),
|
|
147
155
|
async (c) => {
|