@axium/server 0.24.1 → 0.26.0
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/build/client/_app/immutable/assets/account.dAAx7bby.css +1 -0
- package/build/client/_app/immutable/assets/account.dAAx7bby.css.br +0 -0
- package/build/client/_app/immutable/assets/account.dAAx7bby.css.gz +0 -0
- package/build/client/_app/immutable/assets/list.DVGH0BeP.css +1 -0
- package/build/client/_app/immutable/assets/list.DVGH0BeP.css.br +0 -0
- package/build/client/_app/immutable/assets/list.DVGH0BeP.css.gz +0 -0
- package/build/client/_app/immutable/assets/styles.D8SZ-PeY.css +1 -0
- package/build/client/_app/immutable/assets/styles.D8SZ-PeY.css.br +2 -0
- package/build/client/_app/immutable/assets/styles.D8SZ-PeY.css.gz +0 -0
- package/build/client/_app/immutable/chunks/46qGscyh.js +2 -0
- package/build/client/_app/immutable/chunks/46qGscyh.js.br +0 -0
- package/build/client/_app/immutable/chunks/46qGscyh.js.gz +0 -0
- package/build/client/_app/immutable/chunks/B2Vkpbkw.js +2 -0
- package/build/client/_app/immutable/chunks/B2Vkpbkw.js.br +0 -0
- package/build/client/_app/immutable/chunks/B2Vkpbkw.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BKixenYx.js +1 -0
- package/build/client/_app/immutable/chunks/BKixenYx.js.br +0 -0
- package/build/client/_app/immutable/chunks/BKixenYx.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BLtAtlP3.js +1 -0
- package/build/client/_app/immutable/chunks/BLtAtlP3.js.br +2 -0
- package/build/client/_app/immutable/chunks/BLtAtlP3.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BNTlty5m.js +1 -0
- package/build/client/_app/immutable/chunks/BNTlty5m.js.br +0 -0
- package/build/client/_app/immutable/chunks/BNTlty5m.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Beh6Ec8J.js +1 -0
- package/build/client/_app/immutable/chunks/Beh6Ec8J.js.br +0 -0
- package/build/client/_app/immutable/chunks/Beh6Ec8J.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BrUe-Qen.js +1 -0
- package/build/client/_app/immutable/chunks/BrUe-Qen.js.br +0 -0
- package/build/client/_app/immutable/chunks/BrUe-Qen.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Bs4cD_pX.js +1 -0
- package/build/client/_app/immutable/chunks/Bs4cD_pX.js.br +0 -0
- package/build/client/_app/immutable/chunks/Bs4cD_pX.js.gz +0 -0
- package/build/client/_app/immutable/chunks/C62F-tXu.js +1 -0
- package/build/client/_app/immutable/chunks/C62F-tXu.js.br +1 -0
- package/build/client/_app/immutable/chunks/C62F-tXu.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CUBtP2L9.js +23 -0
- package/build/client/_app/immutable/chunks/CUBtP2L9.js.br +0 -0
- package/build/client/_app/immutable/chunks/CUBtP2L9.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Ch16TNvP.js +1 -0
- package/build/client/_app/immutable/chunks/Ch16TNvP.js.br +0 -0
- package/build/client/_app/immutable/chunks/Ch16TNvP.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CoYD6HNm.js +1 -0
- package/build/client/_app/immutable/chunks/CoYD6HNm.js.br +0 -0
- package/build/client/_app/immutable/chunks/CoYD6HNm.js.gz +0 -0
- package/build/client/_app/immutable/chunks/D40Zn55h.js +1 -0
- package/build/client/_app/immutable/chunks/D40Zn55h.js.br +0 -0
- package/build/client/_app/immutable/chunks/D40Zn55h.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DW7-1esk.js +21 -0
- package/build/client/_app/immutable/chunks/DW7-1esk.js.br +0 -0
- package/build/client/_app/immutable/chunks/DW7-1esk.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DY4fWHx_.js +1 -0
- package/build/client/_app/immutable/chunks/DY4fWHx_.js.br +0 -0
- package/build/client/_app/immutable/chunks/DY4fWHx_.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DvOBbqVY.js +1 -0
- package/build/client/_app/immutable/chunks/DvOBbqVY.js.br +0 -0
- package/build/client/_app/immutable/chunks/DvOBbqVY.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DwZYWemd.js +1 -0
- package/build/client/_app/immutable/chunks/DwZYWemd.js.br +0 -0
- package/build/client/_app/immutable/chunks/DwZYWemd.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Dy2Ho0cF.js +1 -0
- package/build/client/_app/immutable/chunks/Dy2Ho0cF.js.br +0 -0
- package/build/client/_app/immutable/chunks/Dy2Ho0cF.js.gz +0 -0
- package/build/client/_app/immutable/chunks/FTv0qR3w.js +1 -0
- package/build/client/_app/immutable/chunks/FTv0qR3w.js.br +0 -0
- package/build/client/_app/immutable/chunks/FTv0qR3w.js.gz +0 -0
- package/build/client/_app/immutable/chunks/NeK0YGoY.js +1 -0
- package/build/client/_app/immutable/chunks/NeK0YGoY.js.br +0 -0
- package/build/client/_app/immutable/chunks/NeK0YGoY.js.gz +0 -0
- package/build/client/_app/immutable/chunks/aArGsq9c.js +1 -0
- package/build/client/_app/immutable/chunks/aArGsq9c.js.br +0 -0
- package/build/client/_app/immutable/chunks/aArGsq9c.js.gz +0 -0
- package/build/client/_app/immutable/chunks/lH47zGKU.js +1 -0
- package/build/client/_app/immutable/chunks/lH47zGKU.js.br +0 -0
- package/build/client/_app/immutable/chunks/lH47zGKU.js.gz +0 -0
- package/build/client/_app/immutable/chunks/sMHjBQqw.js +1 -0
- package/build/client/_app/immutable/chunks/sMHjBQqw.js.br +0 -0
- package/build/client/_app/immutable/chunks/sMHjBQqw.js.gz +0 -0
- package/build/client/_app/immutable/chunks/vQfHcJV6.js +2 -0
- package/build/client/_app/immutable/chunks/vQfHcJV6.js.br +0 -0
- package/build/client/_app/immutable/chunks/vQfHcJV6.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.pLVZKpSD.js +2 -0
- package/build/client/_app/immutable/entry/app.pLVZKpSD.js.br +0 -0
- package/build/client/_app/immutable/entry/app.pLVZKpSD.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.CUaVsIrY.js +1 -0
- package/build/client/_app/immutable/entry/start.CUaVsIrY.js.br +2 -0
- package/build/client/_app/immutable/entry/start.CUaVsIrY.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.D7hET-Bq.js +1 -0
- package/build/client/_app/immutable/nodes/0.D7hET-Bq.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.D7hET-Bq.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.BWU-JJm_.js +1 -0
- package/build/client/_app/immutable/nodes/1.BWU-JJm_.js.br +2 -0
- package/build/client/_app/immutable/nodes/1.BWU-JJm_.js.gz +0 -0
- package/build/client/_app/immutable/nodes/10.C5N2XBee.js +1 -0
- package/build/client/_app/immutable/nodes/10.C5N2XBee.js.br +0 -0
- package/build/client/_app/immutable/nodes/10.C5N2XBee.js.gz +0 -0
- package/build/client/_app/immutable/nodes/11.CerbuSAv.js +1 -0
- package/build/client/_app/immutable/nodes/11.CerbuSAv.js.br +0 -0
- package/build/client/_app/immutable/nodes/11.CerbuSAv.js.gz +0 -0
- package/build/client/_app/immutable/nodes/12.Z4B9zS78.js +1 -0
- package/build/client/_app/immutable/nodes/12.Z4B9zS78.js.br +0 -0
- package/build/client/_app/immutable/nodes/12.Z4B9zS78.js.gz +0 -0
- package/build/client/_app/immutable/nodes/13.CuICShck.js +1 -0
- package/build/client/_app/immutable/nodes/13.CuICShck.js.br +0 -0
- package/build/client/_app/immutable/nodes/13.CuICShck.js.gz +0 -0
- package/build/client/_app/immutable/nodes/14.BSEF5oaF.js +1 -0
- package/build/client/_app/immutable/nodes/14.BSEF5oaF.js.br +0 -0
- package/build/client/_app/immutable/nodes/14.BSEF5oaF.js.gz +0 -0
- package/build/client/_app/immutable/nodes/15.D1nsmo6j.js +1 -0
- package/build/client/_app/immutable/nodes/15.D1nsmo6j.js.br +0 -0
- package/build/client/_app/immutable/nodes/15.D1nsmo6j.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.DQ1JcYgz.js +1 -0
- package/build/client/_app/immutable/nodes/2.DQ1JcYgz.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.DQ1JcYgz.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.BJp2JEtW.js +1 -0
- package/build/client/_app/immutable/nodes/3.BJp2JEtW.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.BJp2JEtW.js.gz +0 -0
- package/build/client/_app/immutable/nodes/4.Cvn_QsIx.js +1 -0
- package/build/client/_app/immutable/nodes/4.Cvn_QsIx.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.Cvn_QsIx.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.DgPP9GX3.js +1 -0
- package/build/client/_app/immutable/nodes/5.DgPP9GX3.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.DgPP9GX3.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.DKIzms8i.js +2 -0
- package/build/client/_app/immutable/nodes/6.DKIzms8i.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.DKIzms8i.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.3UigVXV4.js +1 -0
- package/build/client/_app/immutable/nodes/7.3UigVXV4.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.3UigVXV4.js.gz +0 -0
- package/build/client/_app/immutable/nodes/8.B8s2TdNQ.js +1 -0
- package/build/client/_app/immutable/nodes/8.B8s2TdNQ.js.br +0 -0
- package/build/client/_app/immutable/nodes/8.B8s2TdNQ.js.gz +0 -0
- package/build/client/_app/immutable/nodes/9.LBMMe2kc.js +1 -0
- package/build/client/_app/immutable/nodes/9.LBMMe2kc.js.br +0 -0
- package/build/client/_app/immutable/nodes/9.LBMMe2kc.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/client/styles.css +28 -0
- package/build/client/styles.css.br +0 -0
- package/build/client/styles.css.gz +0 -0
- package/build/handler.js +20 -3
- package/build/server/chunks/0-CNbALTKz.js +9 -0
- package/build/server/chunks/0-CNbALTKz.js.map +1 -0
- package/build/server/chunks/1-Dgxy393u.js +9 -0
- package/build/server/chunks/1-Dgxy393u.js.map +1 -0
- package/build/server/chunks/10-DovmbqKa.js +14 -0
- package/build/server/chunks/10-DovmbqKa.js.map +1 -0
- package/build/server/chunks/11-CRK_ubcl.js +14 -0
- package/build/server/chunks/11-CRK_ubcl.js.map +1 -0
- package/build/server/chunks/12-SbQlwMfe.js +9 -0
- package/build/server/chunks/12-SbQlwMfe.js.map +1 -0
- package/build/server/chunks/13-CbniIW7F.js +14 -0
- package/build/server/chunks/13-CbniIW7F.js.map +1 -0
- package/build/server/chunks/14-D9Vb_8Yx.js +9 -0
- package/build/server/chunks/14-D9Vb_8Yx.js.map +1 -0
- package/build/server/chunks/15-D-75Hdef.js +9 -0
- package/build/server/chunks/15-D-75Hdef.js.map +1 -0
- package/build/server/chunks/2-57exN8ae.js +14 -0
- package/build/server/chunks/2-57exN8ae.js.map +1 -0
- package/build/server/chunks/3-DNQft-pY.js +9 -0
- package/build/server/chunks/{2-CXlrhpR6.js.map → 3-DNQft-pY.js.map} +1 -1
- package/build/server/chunks/4-D9Bwp-f8.js +14 -0
- package/build/server/chunks/4-D9Bwp-f8.js.map +1 -0
- package/build/server/chunks/5-COEQwZNP.js +14 -0
- package/build/server/chunks/5-COEQwZNP.js.map +1 -0
- package/build/server/chunks/6-RT4yiDcP.js +14 -0
- package/build/server/chunks/6-RT4yiDcP.js.map +1 -0
- package/build/server/chunks/7-CVqF_r5D.js +14 -0
- package/build/server/chunks/7-CVqF_r5D.js.map +1 -0
- package/build/server/chunks/8-C5SO-sVH.js +14 -0
- package/build/server/chunks/8-C5SO-sVH.js.map +1 -0
- package/build/server/chunks/9-DoCOKtY-.js +14 -0
- package/build/server/chunks/9-DoCOKtY-.js.map +1 -0
- package/build/server/chunks/FormDialog-ZCY0chY1.js +102 -0
- package/build/server/chunks/FormDialog-ZCY0chY1.js.map +1 -0
- package/build/server/chunks/Icon-BVo9qbDf.js +30 -0
- package/build/server/chunks/Icon-BVo9qbDf.js.map +1 -0
- package/build/server/chunks/Logout-CmBZgu0j.js +46 -0
- package/build/server/chunks/Logout-CmBZgu0j.js.map +1 -0
- package/build/server/chunks/_layout.svelte-DuS006VZ.js +33 -0
- package/build/server/chunks/_layout.svelte-DuS006VZ.js.map +1 -0
- package/build/server/chunks/_page.svelte-BFVobcI7.js +14 -0
- package/build/server/chunks/_page.svelte-BFVobcI7.js.map +1 -0
- package/build/server/chunks/_page.svelte-B_cvhWJS.js +66 -0
- package/build/server/chunks/_page.svelte-B_cvhWJS.js.map +1 -0
- package/build/server/chunks/_page.svelte-BriaBR9l.js +28 -0
- package/build/server/chunks/_page.svelte-BriaBR9l.js.map +1 -0
- package/build/server/chunks/_page.svelte-BtQQzT7H.js +72 -0
- package/build/server/chunks/_page.svelte-BtQQzT7H.js.map +1 -0
- package/build/server/chunks/_page.svelte-C8D3c3yB.js +64 -0
- package/build/server/chunks/_page.svelte-C8D3c3yB.js.map +1 -0
- package/build/server/chunks/_page.svelte-CVSb9eHQ.js +24 -0
- package/build/server/chunks/_page.svelte-CVSb9eHQ.js.map +1 -0
- package/build/server/chunks/_page.svelte-CwRjZqL7.js +107 -0
- package/build/server/chunks/_page.svelte-CwRjZqL7.js.map +1 -0
- package/build/server/chunks/_page.svelte-D9A9RYjx.js +233 -0
- package/build/server/chunks/_page.svelte-D9A9RYjx.js.map +1 -0
- package/build/server/chunks/_page.svelte-DGhwqWMM.js +34 -0
- package/build/server/chunks/_page.svelte-DGhwqWMM.js.map +1 -0
- package/build/server/chunks/_page.svelte-DTvnX95_.js +75 -0
- package/build/server/chunks/_page.svelte-DTvnX95_.js.map +1 -0
- package/build/server/chunks/_page.svelte-DUfwpXfC.js +122 -0
- package/build/server/chunks/_page.svelte-DUfwpXfC.js.map +1 -0
- package/build/server/chunks/_page.svelte-DxDoD3rZ.js +37 -0
- package/build/server/chunks/_page.svelte-DxDoD3rZ.js.map +1 -0
- package/build/server/chunks/_page.svelte-VDBvShZ8.js +6 -0
- package/build/server/chunks/_page.svelte-VDBvShZ8.js.map +1 -0
- package/build/server/chunks/account-Bf_llRe2.js +446 -0
- package/build/server/chunks/account-Bf_llRe2.js.map +1 -0
- package/build/server/chunks/auth_redirect-olBYiIF2.js +24 -0
- package/build/server/chunks/auth_redirect-olBYiIF2.js.map +1 -0
- package/build/server/chunks/color-K_MR7m8s.js +14 -0
- package/build/server/chunks/color-K_MR7m8s.js.map +1 -0
- package/build/server/chunks/context-R2425nfV.js +64 -0
- package/build/server/chunks/context-R2425nfV.js.map +1 -0
- package/build/server/chunks/{error.svelte-DNQXZmIO.js → error.svelte-CkSCwrMJ.js} +7 -6
- package/build/server/chunks/error.svelte-CkSCwrMJ.js.map +1 -0
- package/build/server/chunks/index-CIEcmmdN.js +890 -0
- package/build/server/chunks/index-CIEcmmdN.js.map +1 -0
- package/build/server/chunks/{index-CvHf_GW2.js → index-Tt4zVDIZ.js} +843 -438
- package/build/server/chunks/index-Tt4zVDIZ.js.map +1 -0
- package/build/server/chunks/layout.svelte-UxsTmhKc.js +8 -0
- package/build/server/chunks/layout.svelte-UxsTmhKc.js.map +1 -0
- package/build/server/chunks/{string-DLbvtT1R.js → numbers-DL8C9q4W.js} +1 -71
- package/build/server/chunks/numbers-DL8C9q4W.js.map +1 -0
- package/build/server/chunks/{FormDialog-CB-2YGWi.js → user2-CRfK67II.js} +12 -206
- package/build/server/chunks/user2-CRfK67II.js.map +1 -0
- package/build/server/chunks/utils-h74ns7K6.js.map +1 -1
- package/build/server/index.js +2304 -1140
- package/build/server/index.js.map +1 -1
- package/build/server/manifest.js +78 -13
- package/build/server/manifest.js.map +1 -1
- package/dist/acl.d.ts +1 -2
- package/dist/acl.js +1 -1
- package/dist/api/acl.js +4 -4
- package/dist/api/admin.d.ts +1 -0
- package/dist/api/admin.js +152 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/metadata.js +5 -5
- package/dist/api/passkeys.js +10 -10
- package/dist/api/register.js +4 -4
- package/dist/api/session.js +5 -5
- package/dist/api/users.js +52 -49
- package/dist/audit.d.ts +8 -39
- package/dist/audit.js +13 -16
- package/dist/auth.d.ts +4 -11
- package/dist/auth.js +4 -4
- package/dist/cli.js +515 -559
- package/dist/config.d.ts +26 -16
- package/dist/config.js +65 -36
- package/dist/database.d.ts +3 -4
- package/dist/database.js +19 -18
- package/dist/internal_requests.d.ts +3 -0
- package/dist/internal_requests.js +119 -0
- package/dist/io.d.ts +0 -49
- package/dist/io.js +23 -171
- package/dist/linking.d.ts +0 -1
- package/dist/linking.js +5 -8
- package/dist/requests.d.ts +10 -6
- package/dist/requests.js +17 -15
- package/dist/routes.d.ts +6 -10
- package/dist/routes.js +7 -8
- package/dist/serve.d.ts +7 -2
- package/dist/serve.js +170 -13
- package/dist/state.js +2 -1
- package/package.json +8 -7
- package/routes/account/+page.svelte +5 -109
- package/routes/admin/+layout.svelte +56 -0
- package/routes/admin/+layout.ts +31 -0
- package/routes/admin/+page.svelte +39 -0
- package/routes/admin/+page.ts +7 -0
- package/routes/admin/audit/+page.svelte +158 -0
- package/routes/admin/audit/+page.ts +22 -0
- package/routes/admin/audit/[id]/+page.svelte +43 -0
- package/routes/admin/audit/[id]/+page.ts +9 -0
- package/routes/admin/audit/styles.css +31 -0
- package/routes/admin/config/+page.svelte +28 -0
- package/routes/admin/config/+page.ts +9 -0
- package/routes/admin/plugins/+page.svelte +23 -0
- package/routes/admin/plugins/+page.ts +7 -0
- package/routes/admin/users/+page.svelte +60 -0
- package/routes/admin/users/+page.ts +9 -0
- package/routes/admin/users/[id]/+page.svelte +108 -0
- package/routes/admin/users/[id]/+page.ts +17 -0
- package/routes/login/client/+page.svelte +72 -0
- package/routes/login/client/+page.ts +27 -0
- package/routes/tsconfig.json +1 -1
- package/svelte.config.js +4 -10
- package/{web/template.html → template.html} +1 -1
- package/{web/tsconfig.json → web.tsconfig.json} +2 -2
- package/build/client/_app/immutable/chunks/B1E1cVbi.js +0 -1
- package/build/client/_app/immutable/chunks/B1E1cVbi.js.br +0 -0
- package/build/client/_app/immutable/chunks/B1E1cVbi.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CIywFg5g.js +0 -3
- package/build/client/_app/immutable/chunks/CIywFg5g.js.br +0 -0
- package/build/client/_app/immutable/chunks/CIywFg5g.js.gz +0 -0
- package/build/client/_app/immutable/chunks/D3hk2v8y.js +0 -1
- package/build/client/_app/immutable/chunks/D3hk2v8y.js.br +0 -2
- package/build/client/_app/immutable/chunks/D3hk2v8y.js.gz +0 -0
- package/build/client/_app/immutable/chunks/D4Bce_hb.js +0 -1
- package/build/client/_app/immutable/chunks/D4Bce_hb.js.br +0 -0
- package/build/client/_app/immutable/chunks/D4Bce_hb.js.gz +0 -0
- package/build/client/_app/immutable/chunks/D9TfJrfD.js +0 -1
- package/build/client/_app/immutable/chunks/D9TfJrfD.js.br +0 -0
- package/build/client/_app/immutable/chunks/D9TfJrfD.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DJeR1n-B.js +0 -51
- package/build/client/_app/immutable/chunks/DJeR1n-B.js.br +0 -0
- package/build/client/_app/immutable/chunks/DJeR1n-B.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DsnmJJEf.js +0 -1
- package/build/client/_app/immutable/chunks/DsnmJJEf.js.br +0 -2
- package/build/client/_app/immutable/chunks/DsnmJJEf.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Dy1O3iBu.js +0 -2
- package/build/client/_app/immutable/chunks/Dy1O3iBu.js.br +0 -0
- package/build/client/_app/immutable/chunks/Dy1O3iBu.js.gz +0 -0
- package/build/client/_app/immutable/chunks/pba7IodQ.js +0 -1
- package/build/client/_app/immutable/chunks/pba7IodQ.js.br +0 -0
- package/build/client/_app/immutable/chunks/pba7IodQ.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.ChtScU8h.js +0 -2
- package/build/client/_app/immutable/entry/app.ChtScU8h.js.br +0 -0
- package/build/client/_app/immutable/entry/app.ChtScU8h.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.DdjgBKiR.js +0 -1
- package/build/client/_app/immutable/entry/start.DdjgBKiR.js.br +0 -2
- package/build/client/_app/immutable/entry/start.DdjgBKiR.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js +0 -1
- package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.DlE8ZTIF.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.DRjfV_5C.js +0 -1
- package/build/client/_app/immutable/nodes/1.DRjfV_5C.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.DRjfV_5C.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.CvEpuMc7.js +0 -1
- package/build/client/_app/immutable/nodes/2.CvEpuMc7.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.CvEpuMc7.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.CVudd8x2.js +0 -7
- package/build/client/_app/immutable/nodes/3.CVudd8x2.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.CVudd8x2.js.gz +0 -0
- package/build/client/_app/immutable/nodes/4.Dhj0R0r7.js +0 -1
- package/build/client/_app/immutable/nodes/4.Dhj0R0r7.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.Dhj0R0r7.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.CGoBaVII.js +0 -1
- package/build/client/_app/immutable/nodes/5.CGoBaVII.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.CGoBaVII.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.BtB2uWXy.js +0 -1
- package/build/client/_app/immutable/nodes/6.BtB2uWXy.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.BtB2uWXy.js.gz +0 -0
- package/build/server/chunks/0-DgHTujtC.js +0 -9
- package/build/server/chunks/0-DgHTujtC.js.map +0 -1
- package/build/server/chunks/1-B3zVLOO8.js +0 -9
- package/build/server/chunks/1-B3zVLOO8.js.map +0 -1
- package/build/server/chunks/2-CXlrhpR6.js +0 -9
- package/build/server/chunks/3-CGT4Ugys.js +0 -13
- package/build/server/chunks/3-CGT4Ugys.js.map +0 -1
- package/build/server/chunks/4-BscEiwUk.js +0 -9
- package/build/server/chunks/4-BscEiwUk.js.map +0 -1
- package/build/server/chunks/5-H0ePIJBE.js +0 -9
- package/build/server/chunks/5-H0ePIJBE.js.map +0 -1
- package/build/server/chunks/6-BrPpcagX.js +0 -9
- package/build/server/chunks/6-BrPpcagX.js.map +0 -1
- package/build/server/chunks/FormDialog-CB-2YGWi.js.map +0 -1
- package/build/server/chunks/Logout-LKOt-AST.js +0 -45
- package/build/server/chunks/Logout-LKOt-AST.js.map +0 -1
- package/build/server/chunks/_page.svelte-B1LK5J87.js +0 -11
- package/build/server/chunks/_page.svelte-B1LK5J87.js.map +0 -1
- package/build/server/chunks/_page.svelte-CMtkwvbP.js +0 -68
- package/build/server/chunks/_page.svelte-CMtkwvbP.js.map +0 -1
- package/build/server/chunks/_page.svelte-CbI2KxeA.js +0 -62
- package/build/server/chunks/_page.svelte-CbI2KxeA.js.map +0 -1
- package/build/server/chunks/_page.svelte-D1_WJoyP.js +0 -6
- package/build/server/chunks/_page.svelte-D1_WJoyP.js.map +0 -1
- package/build/server/chunks/_page.svelte-d01Hl2Ia.js +0 -639
- package/build/server/chunks/_page.svelte-d01Hl2Ia.js.map +0 -1
- package/build/server/chunks/error.svelte-DNQXZmIO.js.map +0 -1
- package/build/server/chunks/hooks.server-CQhG9POo.js +0 -17298
- package/build/server/chunks/hooks.server-CQhG9POo.js.map +0 -1
- package/build/server/chunks/index-CvHf_GW2.js.map +0 -1
- package/build/server/chunks/index-RTKpMYZ1.js +0 -397
- package/build/server/chunks/index-RTKpMYZ1.js.map +0 -1
- package/build/server/chunks/layout.svelte-BSvrn-4a.js +0 -8
- package/build/server/chunks/layout.svelte-BSvrn-4a.js.map +0 -1
- package/build/server/chunks/string-DLbvtT1R.js.map +0 -1
- package/dist/apps.d.ts +0 -6
- package/dist/apps.js +0 -6
- package/dist/plugins.d.ts +0 -49
- package/dist/plugins.js +0 -80
- package/dist/sveltekit.d.ts +0 -8
- package/dist/sveltekit.js +0 -60
- package/web/hooks.server.ts +0 -4
- /package/{axiumd.service → axium.service} +0 -0
package/dist/cli.js
CHANGED
|
@@ -51,331 +51,34 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
51
51
|
var e = new Error(message);
|
|
52
52
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
53
53
|
});
|
|
54
|
+
import { apps } from '@axium/core';
|
|
55
|
+
import { AuditFilter, severityNames } from '@axium/core/audit';
|
|
54
56
|
import { formatDateRange } from '@axium/core/format';
|
|
57
|
+
import { outputDaemonStatus, io, pluginText } from '@axium/core/node';
|
|
58
|
+
import { _findPlugin, plugins } from '@axium/core/plugins';
|
|
55
59
|
import { Argument, Option, program } from 'commander';
|
|
56
|
-
import { spawnSync } from 'node:child_process';
|
|
57
60
|
import { access } from 'node:fs/promises';
|
|
58
|
-
import { join } from 'node:path/posix';
|
|
61
|
+
import { join, resolve } from 'node:path/posix';
|
|
59
62
|
import { createInterface } from 'node:readline/promises';
|
|
60
63
|
import { styleText } from 'node:util';
|
|
61
|
-
import {
|
|
64
|
+
import { getByString, isJSON, setByString } from 'utilium';
|
|
62
65
|
import * as z from 'zod';
|
|
63
66
|
import $pkg from '../package.json' with { type: 'json' };
|
|
64
|
-
import {
|
|
65
|
-
import { audit, getEvents, Severity, styleSeverity } from './audit.js';
|
|
67
|
+
import { audit, getEvents, styleSeverity } from './audit.js';
|
|
66
68
|
import config, { configFiles, FileSchema, saveConfigTo } from './config.js';
|
|
67
69
|
import * as db from './database.js';
|
|
68
|
-
import
|
|
70
|
+
import { _portActions, _portMethods, restrictedPorts, systemDir } from './io.js';
|
|
69
71
|
import { linkRoutes, listRouteLinks, unlinkRoutes } from './linking.js';
|
|
70
|
-
import {
|
|
71
|
-
import { serveSvelteKit } from './serve.js';
|
|
72
|
-
function readline() {
|
|
73
|
-
const rl = createInterface({
|
|
74
|
-
input: process.stdin,
|
|
75
|
-
output: process.stdout,
|
|
76
|
-
});
|
|
77
|
-
return Object.assign(rl, {
|
|
78
|
-
[Symbol.dispose]: rl.close.bind(rl),
|
|
79
|
-
});
|
|
80
|
-
}
|
|
72
|
+
import { serve } from './serve.js';
|
|
81
73
|
function userText(user, bold = false) {
|
|
82
74
|
const text = `${user.name} <${user.email}> (${user.id})`;
|
|
83
75
|
return bold ? styleText('bold', text) : text;
|
|
84
76
|
}
|
|
85
|
-
program
|
|
86
|
-
.version($pkg.version)
|
|
87
|
-
.name('axium')
|
|
88
|
-
.description('Axium server CLI')
|
|
89
|
-
.configureHelp({ showGlobalOptions: true })
|
|
90
|
-
.option('--debug', 'override debug mode')
|
|
91
|
-
.option('--no-debug', 'override debug mode')
|
|
92
|
-
.option('-c, --config <path>', 'path to the config file');
|
|
93
|
-
program.on('option:debug', () => config.set({ debug: true }));
|
|
94
|
-
program.on('option:config', () => void config.load(program.opts().config));
|
|
95
|
-
const noAutoDB = ['init', 'serve', 'check'];
|
|
96
|
-
program.hook('preAction', async function (_, action) {
|
|
97
|
-
await config.loadDefaults();
|
|
98
|
-
const opt = action.optsWithGlobals();
|
|
99
|
-
opt.force && io.output.warn('--force: Protections disabled.');
|
|
100
|
-
if (typeof opt.debug == 'boolean') {
|
|
101
|
-
config.set({ debug: opt.debug });
|
|
102
|
-
io._setDebugOutput(opt.debug);
|
|
103
|
-
}
|
|
104
|
-
try {
|
|
105
|
-
db.connect();
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
if (!noAutoDB.includes(action.name()))
|
|
109
|
-
throw e;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
program.hook('postAction', async (_, action) => {
|
|
113
|
-
if (!noAutoDB.includes(action.name()))
|
|
114
|
-
await db.database.destroy();
|
|
115
|
-
});
|
|
116
|
-
// Options shared by multiple (sub)commands
|
|
117
|
-
const opts = {
|
|
118
|
-
// database specific
|
|
119
|
-
host: new Option('-H, --host <host>', 'the host of the database.').argParser(value => {
|
|
120
|
-
const [hostname, port] = value?.split(':') ?? [];
|
|
121
|
-
config.db.host = hostname || config.db.host;
|
|
122
|
-
config.db.port = port && Number.isSafeInteger(parseInt(port)) ? parseInt(port) : config.db.port;
|
|
123
|
-
}),
|
|
124
|
-
check: new Option('--check', 'check the database schema after initialization').default(false),
|
|
125
|
-
force: new Option('-f, --force', 'force the operation').default(false),
|
|
126
|
-
global: new Option('-g, --global', 'apply the operation globally').default(false),
|
|
127
|
-
timeout: new Option('-t, --timeout <ms>', 'how long to wait for commands to complete.').default('1000').argParser(value => {
|
|
128
|
-
const timeout = parseInt(value);
|
|
129
|
-
if (!Number.isSafeInteger(timeout) || timeout < 0)
|
|
130
|
-
io.warn('Invalid timeout value, using default.');
|
|
131
|
-
io.setCommandTimeout(timeout);
|
|
132
|
-
}),
|
|
133
|
-
packagesDir: new Option('-p, --packages-dir <dir>', 'the directory to look for packages in'),
|
|
134
|
-
};
|
|
135
|
-
const axiumDB = program.command('db').alias('database').description('Manage the database').addOption(opts.timeout).addOption(opts.host);
|
|
136
|
-
axiumDB
|
|
137
|
-
.command('init')
|
|
138
|
-
.description('Initialize the database')
|
|
139
|
-
.addOption(opts.force)
|
|
140
|
-
.option('-s, --skip', 'If the user, database, or schema already exists, skip trying to create it.')
|
|
141
|
-
.addOption(opts.check)
|
|
142
|
-
.action(async (_localOpts, _) => {
|
|
143
|
-
const opt = _.optsWithGlobals();
|
|
144
|
-
await db.init(opt).catch(io.handleError);
|
|
145
|
-
});
|
|
146
|
-
axiumDB
|
|
147
|
-
.command('status')
|
|
148
|
-
.alias('stats')
|
|
149
|
-
.description('Check the status of the database')
|
|
150
|
-
.action(async () => {
|
|
151
|
-
try {
|
|
152
|
-
console.log(await db.statText());
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
io.output.error('Unavailable');
|
|
156
|
-
process.exitCode = 1;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
axiumDB
|
|
160
|
-
.command('drop')
|
|
161
|
-
.description('Drop the Axium database and user')
|
|
162
|
-
.addOption(opts.force)
|
|
163
|
-
.action(async (opt) => {
|
|
164
|
-
const stats = await db.count('users', 'passkeys', 'sessions').catch(io.exit);
|
|
165
|
-
if (!opt.force)
|
|
166
|
-
for (const key of ['users', 'passkeys', 'sessions']) {
|
|
167
|
-
if (stats[key] == 0)
|
|
168
|
-
continue;
|
|
169
|
-
io.output.warn(`Database has existing ${key}. Use --force if you really want to drop the database.`);
|
|
170
|
-
process.exit(2);
|
|
171
|
-
}
|
|
172
|
-
await db.uninstall(opt).catch(io.exit);
|
|
173
|
-
});
|
|
174
|
-
axiumDB
|
|
175
|
-
.command('wipe')
|
|
176
|
-
.description('Wipe the database')
|
|
177
|
-
.addOption(opts.force)
|
|
178
|
-
.action(async (opt) => {
|
|
179
|
-
const stats = await db.count('users', 'passkeys', 'sessions').catch(io.exit);
|
|
180
|
-
if (!opt.force)
|
|
181
|
-
for (const key of ['users', 'passkeys', 'sessions']) {
|
|
182
|
-
if (stats[key] == 0)
|
|
183
|
-
continue;
|
|
184
|
-
io.output.warn(`Database has existing ${key}. Use --force if you really want to wipe the database.`);
|
|
185
|
-
process.exit(2);
|
|
186
|
-
}
|
|
187
|
-
await db.wipe(opt).catch(io.exit);
|
|
188
|
-
});
|
|
189
|
-
axiumDB
|
|
190
|
-
.command('check')
|
|
191
|
-
.description('Check the structure of the database')
|
|
192
|
-
.option('-s, --strict', 'Throw errors instead of emitting warnings for most column problems')
|
|
193
|
-
.action(async (opt) => {
|
|
194
|
-
await db.check(opt).catch(io.exit);
|
|
195
|
-
});
|
|
196
|
-
axiumDB
|
|
197
|
-
.command('clean')
|
|
198
|
-
.description('Remove expired rows')
|
|
199
|
-
.addOption(opts.force)
|
|
200
|
-
.action(async (opt) => {
|
|
201
|
-
await db.clean(opt).catch(io.exit);
|
|
202
|
-
});
|
|
203
|
-
axiumDB
|
|
204
|
-
.command('rotate-password')
|
|
205
|
-
.description('Generate a new password for the database user and update the config')
|
|
206
|
-
.action(db.rotatePassword);
|
|
207
|
-
const axiumConfig = program
|
|
208
|
-
.command('config')
|
|
209
|
-
.description('Manage the configuration')
|
|
210
|
-
.addOption(opts.global)
|
|
211
|
-
.option('-j, --json', 'values are JSON encoded')
|
|
212
|
-
.option('-r, --redact', 'Do not output sensitive values');
|
|
213
77
|
function configReplacer(opt) {
|
|
214
78
|
return (key, value) => {
|
|
215
79
|
return opt.redact && ['password', 'secret'].includes(key) ? '[redacted]' : value;
|
|
216
80
|
};
|
|
217
81
|
}
|
|
218
|
-
axiumConfig
|
|
219
|
-
.command('dump')
|
|
220
|
-
.description('Output the entire current configuration')
|
|
221
|
-
.action(() => {
|
|
222
|
-
const opt = axiumConfig.optsWithGlobals();
|
|
223
|
-
const value = config.plain();
|
|
224
|
-
console.log(opt.json ? JSON.stringify(value, configReplacer(opt), 4) : value);
|
|
225
|
-
});
|
|
226
|
-
axiumConfig
|
|
227
|
-
.command('get')
|
|
228
|
-
.description('Get a config value')
|
|
229
|
-
.argument('<key>', 'the key to get')
|
|
230
|
-
.action((key) => {
|
|
231
|
-
const opt = axiumConfig.optsWithGlobals();
|
|
232
|
-
const value = getByString(config.plain(), key);
|
|
233
|
-
console.log(opt.json ? JSON.stringify(value, configReplacer(opt), 4) : value);
|
|
234
|
-
});
|
|
235
|
-
axiumConfig
|
|
236
|
-
.command('set')
|
|
237
|
-
.description('Set a config value. Note setting objects is not supported.')
|
|
238
|
-
.argument('<key>', 'the key to set')
|
|
239
|
-
.argument('<value>', 'the value')
|
|
240
|
-
.action((key, value) => {
|
|
241
|
-
const opt = axiumConfig.optsWithGlobals();
|
|
242
|
-
if (opt.json && !isJSON(value))
|
|
243
|
-
io.exit('Invalid JSON');
|
|
244
|
-
const obj = {};
|
|
245
|
-
setByString(obj, key, opt.json ? JSON.parse(value) : value);
|
|
246
|
-
config.save(obj, opt.global);
|
|
247
|
-
});
|
|
248
|
-
axiumConfig
|
|
249
|
-
.command('list')
|
|
250
|
-
.alias('ls')
|
|
251
|
-
.alias('files')
|
|
252
|
-
.description('List loaded config files')
|
|
253
|
-
.action(() => {
|
|
254
|
-
for (const path of config.files.keys())
|
|
255
|
-
console.log(path);
|
|
256
|
-
});
|
|
257
|
-
axiumConfig
|
|
258
|
-
.command('schema')
|
|
259
|
-
.description('Get the JSON schema for the configuration file')
|
|
260
|
-
.action(() => {
|
|
261
|
-
const opt = axiumConfig.optsWithGlobals();
|
|
262
|
-
const schema = z.toJSONSchema(FileSchema, { io: 'input' });
|
|
263
|
-
console.log(opt.json ? JSON.stringify(schema, configReplacer(opt), 4) : schema);
|
|
264
|
-
});
|
|
265
|
-
const axiumPlugin = program.command('plugin').alias('plugins').description('Manage plugins').addOption(opts.global);
|
|
266
|
-
axiumPlugin
|
|
267
|
-
.command('list')
|
|
268
|
-
.alias('ls')
|
|
269
|
-
.description('List loaded plugins')
|
|
270
|
-
.option('-l, --long', 'use the long listing format')
|
|
271
|
-
.option('--no-versions', 'do not show plugin versions')
|
|
272
|
-
.action((opt) => {
|
|
273
|
-
if (!plugins.size) {
|
|
274
|
-
console.log('No plugins loaded.');
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
if (!opt.long) {
|
|
278
|
-
console.log(Array.from(plugins)
|
|
279
|
-
.map(plugin => plugin.name)
|
|
280
|
-
.join(', '));
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
console.log(styleText('whiteBright', plugins.size + ' plugin(s) loaded:'));
|
|
284
|
-
for (const plugin of plugins) {
|
|
285
|
-
console.log(plugin.name, opt.versions ? plugin.version : '');
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
axiumPlugin
|
|
289
|
-
.command('info')
|
|
290
|
-
.description('Get information about a plugin')
|
|
291
|
-
.argument('<plugin>', 'the plugin to get information about')
|
|
292
|
-
.action((search) => {
|
|
293
|
-
const plugin = resolvePlugin(search);
|
|
294
|
-
if (!plugin)
|
|
295
|
-
io.exit(`Can't find a plugin matching "${search}"`);
|
|
296
|
-
console.log(pluginText(plugin));
|
|
297
|
-
});
|
|
298
|
-
axiumPlugin
|
|
299
|
-
.command('remove')
|
|
300
|
-
.alias('rm')
|
|
301
|
-
.description('Remove a plugin')
|
|
302
|
-
.argument('<plugin>', 'the plugin to remove')
|
|
303
|
-
.action(async (search, opt) => {
|
|
304
|
-
const plugin = resolvePlugin(search);
|
|
305
|
-
if (!plugin)
|
|
306
|
-
io.exit(`Can't find a plugin matching "${search}"`);
|
|
307
|
-
const specifier = getSpecifier(plugin);
|
|
308
|
-
await plugin.hooks.remove?.(opt);
|
|
309
|
-
for (const [path, data] of configFiles) {
|
|
310
|
-
if (!data.plugins)
|
|
311
|
-
continue;
|
|
312
|
-
data.plugins = data.plugins.filter(p => p !== specifier);
|
|
313
|
-
saveConfigTo(path, data);
|
|
314
|
-
}
|
|
315
|
-
plugins.delete(plugin);
|
|
316
|
-
});
|
|
317
|
-
axiumPlugin
|
|
318
|
-
.command('init')
|
|
319
|
-
.alias('setup')
|
|
320
|
-
.alias('install')
|
|
321
|
-
.description('Initialize a plugin. This could include adding tables to the database or linking routes.')
|
|
322
|
-
.addOption(opts.timeout)
|
|
323
|
-
.addOption(opts.check)
|
|
324
|
-
.argument('<plugin>', 'the plugin to initialize')
|
|
325
|
-
.action(async (search, opt) => {
|
|
326
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
327
|
-
try {
|
|
328
|
-
const plugin = resolvePlugin(search);
|
|
329
|
-
if (!plugin)
|
|
330
|
-
io.exit(`Can't find a plugin matching "${search}"`);
|
|
331
|
-
const _ = __addDisposableResource(env_1, db.connect(), true);
|
|
332
|
-
await plugin.hooks.db_init?.({ force: false, ...opt, skip: true });
|
|
333
|
-
}
|
|
334
|
-
catch (e_1) {
|
|
335
|
-
env_1.error = e_1;
|
|
336
|
-
env_1.hasError = true;
|
|
337
|
-
}
|
|
338
|
-
finally {
|
|
339
|
-
const result_1 = __disposeResources(env_1);
|
|
340
|
-
if (result_1)
|
|
341
|
-
await result_1;
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
const axiumApps = program.command('apps').description('Manage Axium apps').addOption(opts.global);
|
|
345
|
-
axiumApps
|
|
346
|
-
.command('list')
|
|
347
|
-
.alias('ls')
|
|
348
|
-
.description('List apps added by plugins')
|
|
349
|
-
.option('-l, --long', 'use the long listing format')
|
|
350
|
-
.option('-b, --builtin', 'include built-in apps')
|
|
351
|
-
.action((opt) => {
|
|
352
|
-
if (!apps.size) {
|
|
353
|
-
console.log('No apps.');
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
if (!opt.long) {
|
|
357
|
-
console.log(Array.from(apps.values().map(app => app.name)).join(', '));
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
console.log(styleText('whiteBright', apps.size + ' app(s) loaded:'));
|
|
361
|
-
for (const app of apps.values()) {
|
|
362
|
-
console.log(app.name, styleText('dim', `(${app.id})`));
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
const lookup = new Argument('<user>', 'the UUID or email of the user to operate on').argParser(async (lookup) => {
|
|
366
|
-
const value = await (lookup.includes('@') ? z.email() : z.uuid())
|
|
367
|
-
.parseAsync(lookup.toLowerCase())
|
|
368
|
-
.catch(() => io.exit('Invalid user ID or email.'));
|
|
369
|
-
const result = await db
|
|
370
|
-
.connect()
|
|
371
|
-
.selectFrom('users')
|
|
372
|
-
.where(value.includes('@') ? 'email' : 'id', '=', value)
|
|
373
|
-
.selectAll()
|
|
374
|
-
.executeTakeFirst();
|
|
375
|
-
if (!result)
|
|
376
|
-
io.exit('No user with matching ID or email.');
|
|
377
|
-
return result;
|
|
378
|
-
});
|
|
379
82
|
/**
|
|
380
83
|
* Updates an array of strings by adding or removing items.
|
|
381
84
|
* Only returns whether the array was updated and diff text for what actually changed.
|
|
@@ -400,45 +103,335 @@ function diffUpdate(original, add, remove) {
|
|
|
400
103
|
});
|
|
401
104
|
return [!!diffs.length, original, diffs.join(', ')];
|
|
402
105
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
.
|
|
411
|
-
.
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
.
|
|
437
|
-
|
|
438
|
-
|
|
106
|
+
var rl, safe, noAutoDB, opts, axiumDB, axiumConfig, axiumPlugin, axiumApps, lookup;
|
|
107
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
108
|
+
try {
|
|
109
|
+
rl = __addDisposableResource(env_1, createInterface({
|
|
110
|
+
input: process.stdin,
|
|
111
|
+
output: process.stdout,
|
|
112
|
+
}), false);
|
|
113
|
+
safe = z.stringbool().default(false).parse(process.env.SAFE?.toLowerCase()) || process.argv.includes('--safe');
|
|
114
|
+
await config.load(join(systemDir, 'config.json'), { safe });
|
|
115
|
+
program
|
|
116
|
+
.version($pkg.version)
|
|
117
|
+
.name('axium')
|
|
118
|
+
.description('Axium server CLI')
|
|
119
|
+
.configureHelp({ showGlobalOptions: true })
|
|
120
|
+
.option('--safe', 'do not execute code from plugins')
|
|
121
|
+
.option('--debug', 'override debug mode')
|
|
122
|
+
.option('--no-debug', 'override debug mode')
|
|
123
|
+
.option('-c, --config <path>', 'path to the config file');
|
|
124
|
+
program.on('option:debug', () => config.set({ debug: true }));
|
|
125
|
+
program.on('option:config', () => void config.load(program.opts().config, { safe }));
|
|
126
|
+
noAutoDB = ['init', 'serve', 'check'];
|
|
127
|
+
program.hook('preAction', async function (_, action) {
|
|
128
|
+
await config.loadDefaults(safe);
|
|
129
|
+
const opt = action.optsWithGlobals();
|
|
130
|
+
opt.force && io.warn('--force: Protections disabled.');
|
|
131
|
+
if (typeof opt.debug == 'boolean') {
|
|
132
|
+
config.set({ debug: opt.debug });
|
|
133
|
+
io._setDebugOutput(opt.debug);
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
db.connect();
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
if (!noAutoDB.includes(action.name()))
|
|
140
|
+
throw e;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
program.hook('postAction', async (_, action) => {
|
|
144
|
+
if (!noAutoDB.includes(action.name()))
|
|
145
|
+
await db.database.destroy();
|
|
146
|
+
});
|
|
147
|
+
// Options shared by multiple (sub)commands
|
|
148
|
+
opts = {
|
|
149
|
+
// database specific
|
|
150
|
+
host: new Option('-H, --host <host>', 'the host of the database.').argParser(value => {
|
|
151
|
+
const [hostname, port] = value?.split(':') ?? [];
|
|
152
|
+
config.db.host = hostname || config.db.host;
|
|
153
|
+
config.db.port = port && Number.isSafeInteger(parseInt(port)) ? parseInt(port) : config.db.port;
|
|
154
|
+
}),
|
|
155
|
+
check: new Option('--check', 'check the database schema after initialization').default(false),
|
|
156
|
+
force: new Option('-f, --force', 'force the operation').default(false),
|
|
157
|
+
global: new Option('-g, --global', 'apply the operation globally').default(false),
|
|
158
|
+
timeout: new Option('-t, --timeout <ms>', 'how long to wait for commands to complete.').default('1000').argParser(value => {
|
|
159
|
+
const timeout = parseInt(value);
|
|
160
|
+
if (!Number.isSafeInteger(timeout) || timeout < 0)
|
|
161
|
+
io.warn('Invalid timeout value, using default.');
|
|
162
|
+
io.setCommandTimeout(timeout);
|
|
163
|
+
}),
|
|
164
|
+
packagesDir: new Option('-p, --packages-dir <dir>', 'the directory to look for packages in'),
|
|
165
|
+
};
|
|
166
|
+
axiumDB = program.command('db').alias('database').description('Manage the database').addOption(opts.timeout).addOption(opts.host);
|
|
167
|
+
axiumDB
|
|
168
|
+
.command('init')
|
|
169
|
+
.description('Initialize the database')
|
|
170
|
+
.addOption(opts.force)
|
|
171
|
+
.option('-s, --skip', 'If the user, database, or schema already exists, skip trying to create it.')
|
|
172
|
+
.addOption(opts.check)
|
|
173
|
+
.action(async (_localOpts, _) => {
|
|
174
|
+
const opt = _.optsWithGlobals();
|
|
175
|
+
await db.init(opt).catch(io.handleError);
|
|
176
|
+
});
|
|
177
|
+
axiumDB
|
|
178
|
+
.command('status')
|
|
179
|
+
.alias('stats')
|
|
180
|
+
.description('Check the status of the database')
|
|
181
|
+
.action(async () => {
|
|
182
|
+
try {
|
|
183
|
+
console.log(await db.statText());
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
io.error('Unavailable');
|
|
187
|
+
process.exitCode = 1;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
axiumDB
|
|
191
|
+
.command('drop')
|
|
192
|
+
.description('Drop the Axium database and user')
|
|
193
|
+
.addOption(opts.force)
|
|
194
|
+
.action(async (opt) => {
|
|
195
|
+
const stats = await db.count('users', 'passkeys', 'sessions').catch(io.exit);
|
|
196
|
+
if (!opt.force)
|
|
197
|
+
for (const key of ['users', 'passkeys', 'sessions']) {
|
|
198
|
+
if (stats[key] == 0)
|
|
199
|
+
continue;
|
|
200
|
+
io.warn(`Database has existing ${key}. Use --force if you really want to drop the database.`);
|
|
201
|
+
process.exit(2);
|
|
202
|
+
}
|
|
203
|
+
await db.uninstall(opt).catch(io.exit);
|
|
204
|
+
});
|
|
205
|
+
axiumDB
|
|
206
|
+
.command('wipe')
|
|
207
|
+
.description('Wipe the database')
|
|
208
|
+
.addOption(opts.force)
|
|
209
|
+
.action(async (opt) => {
|
|
210
|
+
const stats = await db.count('users', 'passkeys', 'sessions').catch(io.exit);
|
|
211
|
+
if (!opt.force)
|
|
212
|
+
for (const key of ['users', 'passkeys', 'sessions']) {
|
|
213
|
+
if (stats[key] == 0)
|
|
214
|
+
continue;
|
|
215
|
+
io.warn(`Database has existing ${key}. Use --force if you really want to wipe the database.`);
|
|
216
|
+
process.exit(2);
|
|
217
|
+
}
|
|
218
|
+
await db.wipe(opt).catch(io.exit);
|
|
219
|
+
});
|
|
220
|
+
axiumDB
|
|
221
|
+
.command('check')
|
|
222
|
+
.description('Check the structure of the database')
|
|
223
|
+
.option('-s, --strict', 'Throw errors instead of emitting warnings for most column problems')
|
|
224
|
+
.action(async (opt) => {
|
|
225
|
+
await db.check(opt).catch(io.exit);
|
|
226
|
+
});
|
|
227
|
+
axiumDB
|
|
228
|
+
.command('clean')
|
|
229
|
+
.description('Remove expired rows')
|
|
230
|
+
.addOption(opts.force)
|
|
231
|
+
.action(async (opt) => {
|
|
232
|
+
await db.clean(opt).catch(io.exit);
|
|
233
|
+
});
|
|
234
|
+
axiumDB
|
|
235
|
+
.command('rotate-password')
|
|
236
|
+
.description('Generate a new password for the database user and update the config')
|
|
237
|
+
.action(db.rotatePassword);
|
|
238
|
+
axiumConfig = program
|
|
239
|
+
.command('config')
|
|
240
|
+
.description('Manage the configuration')
|
|
241
|
+
.addOption(opts.global)
|
|
242
|
+
.option('-j, --json', 'values are JSON encoded')
|
|
243
|
+
.option('-r, --redact', 'Do not output sensitive values');
|
|
244
|
+
axiumConfig
|
|
245
|
+
.command('dump')
|
|
246
|
+
.description('Output the entire current configuration')
|
|
247
|
+
.action(() => {
|
|
248
|
+
const opt = axiumConfig.optsWithGlobals();
|
|
249
|
+
const value = config.plain();
|
|
250
|
+
console.log(opt.json ? JSON.stringify(value, configReplacer(opt), 4) : value);
|
|
251
|
+
});
|
|
252
|
+
axiumConfig
|
|
253
|
+
.command('get')
|
|
254
|
+
.description('Get a config value')
|
|
255
|
+
.argument('<key>', 'the key to get')
|
|
256
|
+
.action((key) => {
|
|
257
|
+
const opt = axiumConfig.optsWithGlobals();
|
|
258
|
+
const value = getByString(config.plain(), key);
|
|
259
|
+
console.log(opt.json ? JSON.stringify(value, configReplacer(opt), 4) : value);
|
|
260
|
+
});
|
|
261
|
+
axiumConfig
|
|
262
|
+
.command('set')
|
|
263
|
+
.description('Set a config value. Note setting objects is not supported.')
|
|
264
|
+
.argument('<key>', 'the key to set')
|
|
265
|
+
.argument('<value>', 'the value')
|
|
266
|
+
.action((key, value) => {
|
|
267
|
+
const opt = axiumConfig.optsWithGlobals();
|
|
268
|
+
if (opt.json && !isJSON(value))
|
|
269
|
+
io.exit('Invalid JSON');
|
|
270
|
+
const obj = {};
|
|
271
|
+
setByString(obj, key, opt.json ? JSON.parse(value) : value);
|
|
272
|
+
config.save(obj, opt.global);
|
|
273
|
+
});
|
|
274
|
+
axiumConfig
|
|
275
|
+
.command('list')
|
|
276
|
+
.alias('ls')
|
|
277
|
+
.alias('files')
|
|
278
|
+
.description('List loaded config files')
|
|
279
|
+
.action(() => {
|
|
280
|
+
for (const path of config.files.keys())
|
|
281
|
+
console.log(path);
|
|
282
|
+
});
|
|
283
|
+
axiumConfig
|
|
284
|
+
.command('schema')
|
|
285
|
+
.description('Get the JSON schema for the configuration file')
|
|
286
|
+
.action(() => {
|
|
287
|
+
const opt = axiumConfig.optsWithGlobals();
|
|
288
|
+
const schema = z.toJSONSchema(FileSchema, { io: 'input' });
|
|
289
|
+
console.log(opt.json ? JSON.stringify(schema, configReplacer(opt), 4) : schema);
|
|
290
|
+
});
|
|
291
|
+
axiumPlugin = program.command('plugin').alias('plugins').description('Manage plugins').addOption(opts.global);
|
|
292
|
+
axiumPlugin
|
|
293
|
+
.command('list')
|
|
294
|
+
.alias('ls')
|
|
295
|
+
.description('List loaded plugins')
|
|
296
|
+
.option('-l, --long', 'use the long listing format')
|
|
297
|
+
.option('--no-versions', 'do not show plugin versions')
|
|
298
|
+
.action((opt) => {
|
|
299
|
+
if (!plugins.size) {
|
|
300
|
+
console.log('No plugins loaded.');
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (!opt.long) {
|
|
304
|
+
console.log(Array.from(plugins.keys()).join(', '));
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
console.log(styleText('whiteBright', plugins.size + ' plugin(s) loaded:'));
|
|
308
|
+
for (const plugin of plugins.values()) {
|
|
309
|
+
console.log(plugin.name, opt.versions ? plugin.version : '');
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
axiumPlugin
|
|
313
|
+
.command('info')
|
|
314
|
+
.description('Get information about a plugin')
|
|
315
|
+
.argument('<plugin>', 'the plugin to get information about')
|
|
316
|
+
.action((search) => {
|
|
317
|
+
const plugin = _findPlugin(search);
|
|
318
|
+
for (const line of pluginText(plugin))
|
|
319
|
+
console.log(line);
|
|
320
|
+
});
|
|
321
|
+
axiumPlugin
|
|
322
|
+
.command('remove')
|
|
323
|
+
.alias('rm')
|
|
324
|
+
.description('Remove a plugin')
|
|
325
|
+
.argument('<plugin>', 'the plugin to remove')
|
|
326
|
+
.action(async (search, opt) => {
|
|
327
|
+
const plugin = _findPlugin(search);
|
|
328
|
+
await plugin._hooks?.remove?.(opt);
|
|
329
|
+
for (const [path, data] of configFiles) {
|
|
330
|
+
if (!data.plugins)
|
|
331
|
+
continue;
|
|
332
|
+
data.plugins = data.plugins.filter(p => p !== plugin.specifier);
|
|
333
|
+
saveConfigTo(path, data);
|
|
334
|
+
}
|
|
335
|
+
plugins.delete(plugin.name);
|
|
336
|
+
});
|
|
337
|
+
axiumPlugin
|
|
338
|
+
.command('init')
|
|
339
|
+
.alias('setup')
|
|
340
|
+
.alias('install')
|
|
341
|
+
.description('Initialize a plugin. This could include adding tables to the database or linking routes.')
|
|
342
|
+
.addOption(opts.timeout)
|
|
343
|
+
.addOption(opts.check)
|
|
344
|
+
.argument('<plugin>', 'the plugin to initialize')
|
|
345
|
+
.action(async (search, opt) => {
|
|
439
346
|
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
440
347
|
try {
|
|
441
|
-
const
|
|
348
|
+
const plugin = _findPlugin(search);
|
|
349
|
+
if (!plugin)
|
|
350
|
+
io.exit(`Can't find a plugin matching "${search}"`);
|
|
351
|
+
const _ = __addDisposableResource(env_2, db.connect(), true);
|
|
352
|
+
await plugin._hooks?.db_init?.({ force: false, ...opt, skip: true });
|
|
353
|
+
}
|
|
354
|
+
catch (e_2) {
|
|
355
|
+
env_2.error = e_2;
|
|
356
|
+
env_2.hasError = true;
|
|
357
|
+
}
|
|
358
|
+
finally {
|
|
359
|
+
const result_1 = __disposeResources(env_2);
|
|
360
|
+
if (result_1)
|
|
361
|
+
await result_1;
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
axiumApps = program.command('apps').description('Manage Axium apps').addOption(opts.global);
|
|
365
|
+
axiumApps
|
|
366
|
+
.command('list')
|
|
367
|
+
.alias('ls')
|
|
368
|
+
.description('List apps added by plugins')
|
|
369
|
+
.option('-l, --long', 'use the long listing format')
|
|
370
|
+
.option('-b, --builtin', 'include built-in apps')
|
|
371
|
+
.action((opt) => {
|
|
372
|
+
if (!apps.size) {
|
|
373
|
+
console.log('No apps.');
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (!opt.long) {
|
|
377
|
+
console.log(Array.from(apps.values().map(app => app.name)).join(', '));
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
console.log(styleText('whiteBright', apps.size + ' app(s) loaded:'));
|
|
381
|
+
for (const app of apps.values()) {
|
|
382
|
+
console.log(app.name, styleText('dim', `(${app.id})`));
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
lookup = new Argument('<user>', 'the UUID or email of the user to operate on').argParser(async (lookup) => {
|
|
386
|
+
const value = await (lookup.includes('@') ? z.email() : z.uuid())
|
|
387
|
+
.parseAsync(lookup.toLowerCase())
|
|
388
|
+
.catch(() => io.exit('Invalid user ID or email.'));
|
|
389
|
+
const result = await db
|
|
390
|
+
.connect()
|
|
391
|
+
.selectFrom('users')
|
|
392
|
+
.where(value.includes('@') ? 'email' : 'id', '=', value)
|
|
393
|
+
.selectAll()
|
|
394
|
+
.executeTakeFirst();
|
|
395
|
+
if (!result)
|
|
396
|
+
io.exit('No user with matching ID or email.');
|
|
397
|
+
return result;
|
|
398
|
+
});
|
|
399
|
+
program
|
|
400
|
+
.command('user')
|
|
401
|
+
.description('Get or change information about a user')
|
|
402
|
+
.addArgument(lookup)
|
|
403
|
+
.option('-S, --sessions', 'show user sessions')
|
|
404
|
+
.option('-P, --passkeys', 'show user passkeys')
|
|
405
|
+
.option('--add-role <role...>', 'add roles to the user')
|
|
406
|
+
.option('--remove-role <role...>', 'remove roles from the user')
|
|
407
|
+
.option('--tag <tag...>', 'Add tags to the user')
|
|
408
|
+
.option('--untag <tag...>', 'Remove tags from the user')
|
|
409
|
+
.option('--delete', 'Delete the user')
|
|
410
|
+
.option('--suspend', 'Suspend the user')
|
|
411
|
+
.addOption(new Option('--unsuspend', 'Un-suspend the user').conflicts('suspend'))
|
|
412
|
+
.action(async (_user, opt) => {
|
|
413
|
+
let user = await _user;
|
|
414
|
+
const [updatedRoles, roles, rolesDiff] = diffUpdate(user.roles, opt.addRole, opt.removeRole);
|
|
415
|
+
const [updatedTags, tags, tagsDiff] = diffUpdate(user.tags, opt.tag, opt.untag);
|
|
416
|
+
const changeSuspend = (opt.suspend || opt.unsuspend) && user.isSuspended != (opt.suspend ?? !opt.unsuspend);
|
|
417
|
+
if (updatedRoles || updatedTags || changeSuspend) {
|
|
418
|
+
user = await db.database
|
|
419
|
+
.updateTable('users')
|
|
420
|
+
.set({ roles, tags, isSuspended: !changeSuspend ? user.isSuspended : (opt.suspend ?? !opt.unsuspend) })
|
|
421
|
+
.returningAll()
|
|
422
|
+
.executeTakeFirstOrThrow()
|
|
423
|
+
.then(u => {
|
|
424
|
+
if (updatedRoles && rolesDiff)
|
|
425
|
+
console.log(`> Updated roles: ${rolesDiff}`);
|
|
426
|
+
if (updatedTags && tagsDiff)
|
|
427
|
+
console.log(`> Updated tags: ${tagsDiff}`);
|
|
428
|
+
if (changeSuspend)
|
|
429
|
+
console.log(opt.suspend ? '> Suspended' : '> Un-suspended');
|
|
430
|
+
return u;
|
|
431
|
+
})
|
|
432
|
+
.catch(e => io.exit('Failed to update user: ' + e.message));
|
|
433
|
+
}
|
|
434
|
+
if (opt.delete) {
|
|
442
435
|
const confirmed = await rl
|
|
443
436
|
.question(`Are you sure you want to delete ${userText(user, true)}? (y/N) `)
|
|
444
437
|
.then(v => z.stringbool().parseAsync(v))
|
|
@@ -453,226 +446,189 @@ program
|
|
|
453
446
|
.then(() => console.log(styleText(['red', 'bold'], '> Deleted')))
|
|
454
447
|
.catch(e => io.exit('Failed to delete user: ' + e.message));
|
|
455
448
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
449
|
+
console.log([
|
|
450
|
+
user.isSuspended && styleText('yellowBright', 'Suspended'),
|
|
451
|
+
user.isAdmin && styleText('redBright', 'Administrator'),
|
|
452
|
+
'UUID: ' + user.id,
|
|
453
|
+
'Name: ' + user.name,
|
|
454
|
+
`Email: ${user.email}, ${user.emailVerified ? 'verified on ' + formatDateRange(user.emailVerified) : styleText(config.auth.email_verification ? 'yellow' : 'dim', 'not verified')}`,
|
|
455
|
+
'Registered ' + formatDateRange(user.registeredAt),
|
|
456
|
+
`Roles: ${user.roles.length ? user.roles.join(', ') : styleText('dim', '(none)')}`,
|
|
457
|
+
`Tags: ${user.tags.length ? user.tags.join(', ') : styleText('dim', '(none)')}`,
|
|
458
|
+
]
|
|
459
|
+
.filter(v => v)
|
|
460
|
+
.join('\n'));
|
|
461
|
+
if (opt.sessions) {
|
|
462
|
+
const sessions = await db.database.selectFrom('sessions').where('userId', '=', user.id).selectAll().execute();
|
|
463
|
+
console.log(styleText('bold', 'Sessions:'));
|
|
464
|
+
if (!sessions.length)
|
|
465
|
+
console.log(styleText('dim', '(none)'));
|
|
466
|
+
else
|
|
467
|
+
for (const session of sessions) {
|
|
468
|
+
console.log(`\t${session.id}\tcreated ${formatDateRange(session.created).padEnd(40)}\texpires ${formatDateRange(session.expires).padEnd(40)}\t${session.elevated ? styleText('yellow', '(elevated)') : ''}`);
|
|
469
|
+
}
|
|
462
470
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
'Name: ' + user.name,
|
|
469
|
-
`Email: ${user.email}, ${user.emailVerified ? 'verified on ' + formatDateRange(user.emailVerified) : styleText(config.auth.email_verification ? 'yellow' : 'dim', 'not verified')}`,
|
|
470
|
-
'Registered ' + formatDateRange(user.registeredAt),
|
|
471
|
-
`Roles: ${user.roles.length ? user.roles.join(', ') : styleText('dim', '(none)')}`,
|
|
472
|
-
`Tags: ${user.tags.length ? user.tags.join(', ') : styleText('dim', '(none)')}`,
|
|
473
|
-
]
|
|
474
|
-
.filter(v => v)
|
|
475
|
-
.join('\n'));
|
|
476
|
-
if (opt.sessions) {
|
|
477
|
-
const sessions = await db.database.selectFrom('sessions').where('userId', '=', user.id).selectAll().execute();
|
|
478
|
-
console.log(styleText('bold', 'Sessions:'));
|
|
479
|
-
if (!sessions.length)
|
|
480
|
-
console.log(styleText('dim', '(none)'));
|
|
481
|
-
else
|
|
482
|
-
for (const session of sessions) {
|
|
483
|
-
console.log(`\t${session.id}\tcreated ${formatDateRange(session.created).padEnd(40)}\texpires ${formatDateRange(session.expires).padEnd(40)}\t${session.elevated ? styleText('yellow', '(elevated)') : ''}`);
|
|
471
|
+
if (opt.passkeys) {
|
|
472
|
+
const passkeys = await db.database.selectFrom('passkeys').where('userId', '=', user.id).selectAll().execute();
|
|
473
|
+
console.log(styleText('bold', 'Passkeys:'));
|
|
474
|
+
for (const passkey of passkeys) {
|
|
475
|
+
console.log(`\t${passkey.id}: created ${formatDateRange(passkey.createdAt).padEnd(40)} used ${passkey.counter} times. ${passkey.deviceType}, ${passkey.backedUp ? '' : 'not '}backed up; transports are [${passkey.transports.join(', ')}], ${passkey.name ? 'named ' + JSON.stringify(passkey.name) : 'unnamed'}.`);
|
|
484
476
|
}
|
|
485
|
-
}
|
|
486
|
-
if (opt.passkeys) {
|
|
487
|
-
const passkeys = await db.database.selectFrom('passkeys').where('userId', '=', user.id).selectAll().execute();
|
|
488
|
-
console.log(styleText('bold', 'Passkeys:'));
|
|
489
|
-
for (const passkey of passkeys) {
|
|
490
|
-
console.log(`\t${passkey.id}: created ${formatDateRange(passkey.createdAt).padEnd(40)} used ${passkey.counter} times. ${passkey.deviceType}, ${passkey.backedUp ? '' : 'not '}backed up; transports are [${passkey.transports.join(', ')}], ${passkey.name ? 'named ' + JSON.stringify(passkey.name) : 'unnamed'}.`);
|
|
491
477
|
}
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
program
|
|
495
|
-
.command('toggle-admin')
|
|
496
|
-
.description('Toggle whether a user is an administrator')
|
|
497
|
-
.addArgument(lookup)
|
|
498
|
-
.action(async (_user) => {
|
|
499
|
-
const user = await _user;
|
|
500
|
-
const isAdmin = !user.isAdmin;
|
|
501
|
-
await db.database.updateTable('users').set({ isAdmin }).where('id', '=', user.id).executeTakeFirstOrThrow();
|
|
502
|
-
await audit('admin_change', undefined, { user: user.id });
|
|
503
|
-
console.log(`${userText(user)} is ${isAdmin ? 'now' : 'no longer'} an administrator. (${styleText(['whiteBright', 'bold'], isAdmin.toString())})`);
|
|
504
|
-
});
|
|
505
|
-
program
|
|
506
|
-
.command('status')
|
|
507
|
-
.alias('stats')
|
|
508
|
-
.description('Get information about the server')
|
|
509
|
-
.addOption(opts.host)
|
|
510
|
-
.action(async () => {
|
|
511
|
-
console.log('Axium Server v' + $pkg.version);
|
|
512
|
-
console.log(styleText('whiteBright', 'Debug mode:'), config.debug ? styleText('yellow', 'enabled') : 'disabled');
|
|
513
|
-
const configFiles = config.files.keys().toArray();
|
|
514
|
-
console.log(styleText('whiteBright', 'Loaded config files:'), styleText(['dim', 'bold'], `(${configFiles.length})`), configFiles.join(', '));
|
|
515
|
-
process.stdout.write(styleText('whiteBright', 'Daemon: '));
|
|
516
|
-
const daemonIs = (sub) => spawnSync('systemctl', ['is-' + sub, 'axiumd'], {
|
|
517
|
-
stdio: 'pipe',
|
|
518
|
-
encoding: 'utf8',
|
|
519
|
-
});
|
|
520
|
-
const { status: dNotActive, stdout: dStatus } = daemonIs('active');
|
|
521
|
-
const { status: dNotFailed } = daemonIs('failed');
|
|
522
|
-
const { stdout: dEnabled } = daemonIs('enabled');
|
|
523
|
-
if (dEnabled.trim() == 'not-found')
|
|
524
|
-
console.log(styleText('dim', 'not found'));
|
|
525
|
-
else {
|
|
526
|
-
process.stdout.write(dEnabled.trim() + ', ');
|
|
527
|
-
const status = dStatus.trim();
|
|
528
|
-
if (!dNotFailed)
|
|
529
|
-
console.log(styleText('red', status));
|
|
530
|
-
else if (!dNotActive)
|
|
531
|
-
console.log(styleText('green', status));
|
|
532
|
-
else
|
|
533
|
-
console.log(styleText('yellow', status));
|
|
534
|
-
}
|
|
535
|
-
process.stdout.write(styleText('whiteBright', 'Database: '));
|
|
536
|
-
try {
|
|
537
|
-
console.log(await db.statText());
|
|
538
|
-
}
|
|
539
|
-
catch {
|
|
540
|
-
console.log(styleText('red', 'Unavailable'));
|
|
541
|
-
}
|
|
542
|
-
console.log(styleText('whiteBright', 'Loaded plugins:'), styleText(['dim', 'bold'], `(${plugins.size || 'none'})`), Array.from(plugins)
|
|
543
|
-
.map(plugin => plugin.name)
|
|
544
|
-
.join(', '));
|
|
545
|
-
for (const plugin of plugins) {
|
|
546
|
-
if (!plugin.statusText)
|
|
547
|
-
continue;
|
|
548
|
-
const text = await plugin.statusText();
|
|
549
|
-
console.log(styleText('bold', plugin.name), plugin.version + ':', text.includes('\n') ? '\n' + text : text);
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
program
|
|
553
|
-
.command('ports')
|
|
554
|
-
.description('Enable or disable use of restricted ports (e.g. 443)')
|
|
555
|
-
.addArgument(new Argument('<action>', 'The action to take').choices(io._portActions))
|
|
556
|
-
.addOption(new Option('-m, --method <method>', 'the method to use').choices(io._portMethods).default('node-cap'))
|
|
557
|
-
.option('-N, --node <path>', 'the path to the node binary')
|
|
558
|
-
.action(async (action, opt) => {
|
|
559
|
-
await io.restrictedPorts({ ...opt, action }).catch(io.handleError);
|
|
560
|
-
});
|
|
561
|
-
program
|
|
562
|
-
.command('init')
|
|
563
|
-
.description('Install Axium server')
|
|
564
|
-
.addOption(opts.force)
|
|
565
|
-
.addOption(opts.host)
|
|
566
|
-
.addOption(opts.check)
|
|
567
|
-
.addOption(opts.packagesDir)
|
|
568
|
-
.action(async (opt) => {
|
|
569
|
-
await db.init({ ...opt, skip: opt.dbSkip }).catch(io.handleError);
|
|
570
|
-
await io.restrictedPorts({ method: 'node-cap', action: 'enable' }).catch(io.handleError);
|
|
571
|
-
linkRoutes(opt);
|
|
572
|
-
});
|
|
573
|
-
program
|
|
574
|
-
.command('serve')
|
|
575
|
-
.description('Start the Axium server')
|
|
576
|
-
.option('-p, --port <port>', 'the port to listen on')
|
|
577
|
-
.option('--ssl <prefix>', 'the prefix for the cert.pem and key.pem SSL files')
|
|
578
|
-
.option('-B, --build', 'the path to a built SvelteKit server handler')
|
|
579
|
-
.action(async (opt) => {
|
|
580
|
-
const server = await serveSvelteKit({
|
|
581
|
-
secure: opt.ssl ? true : config.web.secure,
|
|
582
|
-
ssl_cert: opt.ssl ? join(opt.ssl, 'cert.pem') : config.web.ssl_cert,
|
|
583
|
-
ssl_key: opt.ssl ? join(opt.ssl, 'key.pem') : config.web.ssl_key,
|
|
584
|
-
build: opt.build ?? config.web.build,
|
|
585
478
|
});
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
479
|
+
program
|
|
480
|
+
.command('toggle-admin')
|
|
481
|
+
.description('Toggle whether a user is an administrator')
|
|
482
|
+
.addArgument(lookup)
|
|
483
|
+
.action(async (_user) => {
|
|
484
|
+
const user = await _user;
|
|
485
|
+
const isAdmin = !user.isAdmin;
|
|
486
|
+
await db.database.updateTable('users').set({ isAdmin }).where('id', '=', user.id).executeTakeFirstOrThrow();
|
|
487
|
+
await audit('admin_change', undefined, { user: user.id });
|
|
488
|
+
console.log(`${userText(user)} is ${isAdmin ? 'now' : 'no longer'} an administrator. (${styleText(['whiteBright', 'bold'], isAdmin.toString())})`);
|
|
589
489
|
});
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
if (opt.delete) {
|
|
613
|
-
unlinkRoutes(opt);
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
linkRoutes(opt);
|
|
617
|
-
});
|
|
618
|
-
program
|
|
619
|
-
.command('audit')
|
|
620
|
-
.description('View audit logs')
|
|
621
|
-
.option('-x, --extra', 'Include the extra object when listing events')
|
|
622
|
-
.option('-t, --include-tags', 'Include tags when listing events')
|
|
623
|
-
.addOption(new Option('-s, --summary', 'Summarize audit log entries instead of displaying individual ones').conflicts(['extra', 'includeTags']))
|
|
624
|
-
.optionsGroup('Filters:')
|
|
625
|
-
.addOption(new Option('--since <date>', 'Filter for events since a date').argParser(v => new Date(v)))
|
|
626
|
-
.addOption(new Option('--until <date>', 'Filter for events until a date').argParser(v => new Date(v)))
|
|
627
|
-
.addOption(new Option('--user <uuid|null>', 'Filter for events triggered by a user').argParser(v => {
|
|
628
|
-
try {
|
|
629
|
-
return z.union([z.uuid(), z.literal(['null', '']).transform(() => null)]).parse(v);
|
|
630
|
-
}
|
|
631
|
-
catch (e) {
|
|
632
|
-
throw z.prettifyError(e);
|
|
633
|
-
}
|
|
634
|
-
}))
|
|
635
|
-
.addOption(new Option('--severity <level>', 'Filter for events at or above a severity level')
|
|
636
|
-
.choices(Object.keys(Severity)
|
|
637
|
-
.filter(k => isNaN(Number(k)))
|
|
638
|
-
.map(uncapitalize))
|
|
639
|
-
.argParser(v => {
|
|
640
|
-
const cap = capitalize(v);
|
|
641
|
-
if (!(cap in Severity))
|
|
642
|
-
throw new Error('Invalid severity: ' + v);
|
|
643
|
-
return Severity[cap];
|
|
644
|
-
}))
|
|
645
|
-
.option('--source <source>', 'Filter by source')
|
|
646
|
-
.option('--tag <tag...>', 'Filter by tag(s)')
|
|
647
|
-
.option('--event <event>', 'Filter by event name')
|
|
648
|
-
.action(async (opt) => {
|
|
649
|
-
const events = await getEvents(opt);
|
|
650
|
-
if (opt.summary) {
|
|
651
|
-
const groups = Object.groupBy(events, e => e.severity);
|
|
652
|
-
const maxGroupLength = Math.max(...Object.values(groups).map(g => g.length.toString().length), 0);
|
|
653
|
-
for (const [severity, group] of Object.entries(groups)) {
|
|
654
|
-
if (!group?.length)
|
|
490
|
+
program
|
|
491
|
+
.command('status')
|
|
492
|
+
.alias('stats')
|
|
493
|
+
.description('Get information about the server')
|
|
494
|
+
.addOption(opts.host)
|
|
495
|
+
.action(async () => {
|
|
496
|
+
console.log('Axium Server v' + $pkg.version);
|
|
497
|
+
console.log(styleText('whiteBright', 'Debug mode:'), config.debug ? styleText('yellow', 'enabled') : 'disabled');
|
|
498
|
+
const configFiles = config.files.keys().toArray();
|
|
499
|
+
console.log(styleText('whiteBright', 'Loaded config files:'), styleText(['dim', 'bold'], `(${configFiles.length})`), configFiles.join(', '));
|
|
500
|
+
outputDaemonStatus('axium');
|
|
501
|
+
process.stdout.write(styleText('whiteBright', 'Database: '));
|
|
502
|
+
try {
|
|
503
|
+
console.log(await db.statText());
|
|
504
|
+
}
|
|
505
|
+
catch {
|
|
506
|
+
console.log(styleText('red', 'Unavailable'));
|
|
507
|
+
}
|
|
508
|
+
console.log(styleText('whiteBright', 'Loaded plugins:'), styleText(['dim', 'bold'], `(${plugins.size || 'none'})`), Array.from(plugins.keys()).join(', '));
|
|
509
|
+
for (const plugin of plugins.values()) {
|
|
510
|
+
if (!plugin._hooks?.statusText)
|
|
655
511
|
continue;
|
|
656
|
-
|
|
512
|
+
const text = await plugin._hooks?.statusText();
|
|
513
|
+
console.log(styleText('bold', plugin.name), plugin.version + ':', text.includes('\n') ? '\n' + text : text);
|
|
657
514
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
});
|
|
678
|
-
|
|
515
|
+
});
|
|
516
|
+
program
|
|
517
|
+
.command('ports')
|
|
518
|
+
.description('Enable or disable use of restricted ports (e.g. 443)')
|
|
519
|
+
.addArgument(new Argument('<action>', 'The action to take').choices(_portActions))
|
|
520
|
+
.addOption(new Option('-m, --method <method>', 'the method to use').choices(_portMethods).default('node-cap'))
|
|
521
|
+
.option('-N, --node <path>', 'the path to the node binary')
|
|
522
|
+
.action(async (action, opt) => {
|
|
523
|
+
await restrictedPorts({ ...opt, action }).catch(io.handleError);
|
|
524
|
+
});
|
|
525
|
+
program
|
|
526
|
+
.command('init')
|
|
527
|
+
.description('Install Axium server')
|
|
528
|
+
.addOption(opts.force)
|
|
529
|
+
.addOption(opts.host)
|
|
530
|
+
.addOption(opts.check)
|
|
531
|
+
.addOption(opts.packagesDir)
|
|
532
|
+
.action(async (opt) => {
|
|
533
|
+
await db.init({ ...opt, skip: opt.dbSkip }).catch(io.handleError);
|
|
534
|
+
await restrictedPorts({ method: 'node-cap', action: 'enable' }).catch(io.handleError);
|
|
535
|
+
});
|
|
536
|
+
program
|
|
537
|
+
.command('serve')
|
|
538
|
+
.description('Start the Axium server')
|
|
539
|
+
.option('-p, --port <port>', 'the port to listen on')
|
|
540
|
+
.option('--ssl <prefix>', 'the prefix for the cert.pem and key.pem SSL files')
|
|
541
|
+
.option('-b, --build <path>', 'the path to the handler build')
|
|
542
|
+
.action(async (opt) => {
|
|
543
|
+
const server = await serve({
|
|
544
|
+
secure: opt.ssl ? true : config.web.secure,
|
|
545
|
+
ssl_cert: opt.ssl ? join(opt.ssl, 'cert.pem') : config.web.ssl_cert,
|
|
546
|
+
ssl_key: opt.ssl ? join(opt.ssl, 'key.pem') : config.web.ssl_key,
|
|
547
|
+
build: opt.build ? resolve(opt.build) : undefined,
|
|
548
|
+
});
|
|
549
|
+
const port = !Number.isNaN(Number.parseInt(opt.port ?? '')) ? Number.parseInt(opt.port) : config.web.port;
|
|
550
|
+
server.listen(port, () => {
|
|
551
|
+
console.log('Server is listening on port ' + port);
|
|
552
|
+
});
|
|
553
|
+
});
|
|
554
|
+
program
|
|
555
|
+
.command('link')
|
|
556
|
+
.description('Link routes provided by plugins and the server')
|
|
557
|
+
.addOption(opts.packagesDir)
|
|
558
|
+
.addOption(new Option('-l, --list', 'list route links').conflicts('delete'))
|
|
559
|
+
.option('-d, --delete', 'delete route links')
|
|
560
|
+
.argument('[name...]', 'List of plugin names to operate on. If not specified, operates on all plugins and built-in routes.')
|
|
561
|
+
.action(async function (names) {
|
|
562
|
+
const opt = this.optsWithGlobals();
|
|
563
|
+
if (names.length)
|
|
564
|
+
opt.only = names;
|
|
565
|
+
if (opt.list) {
|
|
566
|
+
for (const link of listRouteLinks(opt)) {
|
|
567
|
+
const idText = link.id.startsWith('#') ? `(${link.id.slice(1)})` : link.id;
|
|
568
|
+
const fromColor = await access(link.from)
|
|
569
|
+
.then(() => 'cyanBright')
|
|
570
|
+
.catch(() => 'redBright');
|
|
571
|
+
console.log(`${idText}:\t ${styleText(fromColor, link.from)}\t->\t${link.to.replace(/.*\/node_modules\//, styleText('dim', '$&'))}`);
|
|
572
|
+
}
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
if (opt.delete) {
|
|
576
|
+
unlinkRoutes(opt);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
linkRoutes(opt);
|
|
580
|
+
});
|
|
581
|
+
program
|
|
582
|
+
.command('audit')
|
|
583
|
+
.description('View audit logs')
|
|
584
|
+
.option('-x, --extra', 'Include the extra object when listing events')
|
|
585
|
+
.option('-t, --include-tags', 'Include tags when listing events')
|
|
586
|
+
.addOption(new Option('-s, --summary', 'Summarize audit log entries instead of displaying individual ones').conflicts(['extra', 'includeTags']))
|
|
587
|
+
.optionsGroup('Filters:')
|
|
588
|
+
.option('--since <date>', 'Filter for events since a date')
|
|
589
|
+
.option('--until <date>', 'Filter for events until a date')
|
|
590
|
+
.option('--user <uuid|null>', 'Filter for events triggered by a user')
|
|
591
|
+
.addOption(new Option('--severity <level>', 'Filter for events at or above a severity level').choices(severityNames))
|
|
592
|
+
.option('--source <source>', 'Filter by source')
|
|
593
|
+
.option('--tag <tag...>', 'Filter by tag(s)')
|
|
594
|
+
.option('--event <event>', 'Filter by event name')
|
|
595
|
+
.action(async (opt) => {
|
|
596
|
+
const filter = await AuditFilter.parseAsync(opt).catch(e => io.exit('Invalid filter: ' + z.prettifyError(e)));
|
|
597
|
+
const events = await getEvents(filter).execute();
|
|
598
|
+
if (opt.summary) {
|
|
599
|
+
const groups = Object.groupBy(events, e => e.severity);
|
|
600
|
+
const maxGroupLength = Math.max(...Object.values(groups).map(g => g.length.toString().length), 0);
|
|
601
|
+
for (const [severity, group] of Object.entries(groups)) {
|
|
602
|
+
if (!group?.length)
|
|
603
|
+
continue;
|
|
604
|
+
console.log(styleText('white', group.length.toString().padStart(maxGroupLength)), styleSeverity(severity, true), 'events. Latest occurred', group.at(-1).timestamp.toLocaleString());
|
|
605
|
+
}
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
let maxSource = 0, maxName = 0, maxTags = 0, maxExtra = 0;
|
|
609
|
+
for (const event of events) {
|
|
610
|
+
maxSource = Math.max(maxSource, event.source.length);
|
|
611
|
+
maxName = Math.max(maxName, event.name.length);
|
|
612
|
+
event._tags = !event.tags.length
|
|
613
|
+
? ''
|
|
614
|
+
: opt.includeTags
|
|
615
|
+
? '# ' + event.tags.join(', ')
|
|
616
|
+
: `(${event.tags.length} tag${event.tags.length == 1 ? '' : 's'})`;
|
|
617
|
+
maxTags = Math.max(maxTags, event._tags.length);
|
|
618
|
+
const extraKeys = Object.keys(event.extra);
|
|
619
|
+
event._extra = !extraKeys.length ? '' : opt.extra ? JSON.stringify(event.extra) : '+' + extraKeys.length;
|
|
620
|
+
maxExtra = Math.max(maxExtra, event._extra.length);
|
|
621
|
+
}
|
|
622
|
+
for (const event of events) {
|
|
623
|
+
console.log(styleSeverity(event.severity, true), styleText('dim', io.prettyDate(event.timestamp)), event.source.padEnd(maxSource), styleText('whiteBright', event.name.padEnd(maxName)), styleText('gray', event._tags.padEnd(maxTags)), 'by', event.userId ? event.userId : styleText(['dim', 'italic'], 'unknown'.padEnd(36)), styleText('blue', event._extra));
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
await program.parseAsync();
|
|
627
|
+
}
|
|
628
|
+
catch (e_1) {
|
|
629
|
+
env_1.error = e_1;
|
|
630
|
+
env_1.hasError = true;
|
|
631
|
+
}
|
|
632
|
+
finally {
|
|
633
|
+
__disposeResources(env_1);
|
|
634
|
+
}
|