@axium/server 0.16.2 → 0.17.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.
Files changed (115) hide show
  1. package/build/client/_app/immutable/chunks/{Dm7VIzXy.js → BIqJFsZ3.js} +1 -1
  2. package/build/client/_app/immutable/chunks/BIqJFsZ3.js.br +0 -0
  3. package/build/client/_app/immutable/chunks/BIqJFsZ3.js.gz +0 -0
  4. package/build/client/_app/immutable/chunks/{DIqfHWch.js → BQEW-soH.js} +1 -1
  5. package/build/client/_app/immutable/chunks/BQEW-soH.js.br +0 -0
  6. package/build/client/_app/immutable/chunks/BQEW-soH.js.gz +0 -0
  7. package/build/client/_app/immutable/chunks/ClV-nJVy.js +31 -0
  8. package/build/client/_app/immutable/chunks/ClV-nJVy.js.br +0 -0
  9. package/build/client/_app/immutable/chunks/ClV-nJVy.js.gz +0 -0
  10. package/build/client/_app/immutable/chunks/{Ccv5p-Lr.js → DQ-d8a5w.js} +2 -2
  11. package/build/client/_app/immutable/chunks/DQ-d8a5w.js.br +0 -0
  12. package/build/client/_app/immutable/chunks/DQ-d8a5w.js.gz +0 -0
  13. package/build/client/_app/immutable/entry/{app.CYeEqzuG.js → app.Bexu3pho.js} +2 -2
  14. package/build/client/_app/immutable/entry/app.Bexu3pho.js.br +0 -0
  15. package/build/client/_app/immutable/entry/app.Bexu3pho.js.gz +0 -0
  16. package/build/client/_app/immutable/entry/start.CkXOtoPI.js +1 -0
  17. package/build/client/_app/immutable/entry/start.CkXOtoPI.js.br +2 -0
  18. package/build/client/_app/immutable/entry/start.CkXOtoPI.js.gz +0 -0
  19. package/build/client/_app/immutable/nodes/{1.BHYgH-pu.js → 1.Di0t29Xx.js} +1 -1
  20. package/build/client/_app/immutable/nodes/1.Di0t29Xx.js.br +0 -0
  21. package/build/client/_app/immutable/nodes/1.Di0t29Xx.js.gz +0 -0
  22. package/build/client/_app/immutable/nodes/{3.C6woCAgZ.js → 3.dB5xKZIR.js} +1 -1
  23. package/build/client/_app/immutable/nodes/3.dB5xKZIR.js.br +0 -0
  24. package/build/client/_app/immutable/nodes/3.dB5xKZIR.js.gz +0 -0
  25. package/build/client/_app/immutable/nodes/{4.CMRdSHhP.js → 4.DC1TCp7U.js} +1 -1
  26. package/build/client/_app/immutable/nodes/4.DC1TCp7U.js.br +0 -0
  27. package/build/client/_app/immutable/nodes/4.DC1TCp7U.js.gz +0 -0
  28. package/build/client/_app/immutable/nodes/5.DGB0QJIF.js +1 -0
  29. package/build/client/_app/immutable/nodes/5.DGB0QJIF.js.br +0 -0
  30. package/build/client/_app/immutable/nodes/5.DGB0QJIF.js.gz +0 -0
  31. package/build/client/_app/immutable/nodes/{6.asNffl6m.js → 6.WTfzqOhT.js} +1 -1
  32. package/build/client/_app/immutable/nodes/6.WTfzqOhT.js.br +0 -0
  33. package/build/client/_app/immutable/nodes/6.WTfzqOhT.js.gz +0 -0
  34. package/build/client/_app/version.json +1 -1
  35. package/build/client/_app/version.json.br +0 -0
  36. package/build/client/_app/version.json.gz +0 -0
  37. package/build/server/chunks/{1-B46rUG8d.js → 1-Db3AncWW.js} +2 -2
  38. package/build/server/chunks/{1-B46rUG8d.js.map → 1-Db3AncWW.js.map} +1 -1
  39. package/build/server/chunks/{3-CeRz1jLd.js → 3-BzEpIldk.js} +3 -3
  40. package/build/server/chunks/{3-CeRz1jLd.js.map → 3-BzEpIldk.js.map} +1 -1
  41. package/build/server/chunks/{4-CPwP8Ikn.js → 4-J7bxt5HT.js} +3 -3
  42. package/build/server/chunks/{4-CPwP8Ikn.js.map → 4-J7bxt5HT.js.map} +1 -1
  43. package/build/server/chunks/{5-xNibYAp4.js → 5-uwjgYAk8.js} +3 -3
  44. package/build/server/chunks/{5-xNibYAp4.js.map → 5-uwjgYAk8.js.map} +1 -1
  45. package/build/server/chunks/{6-CivW166X.js → 6-Cj4cg3MT.js} +3 -3
  46. package/build/server/chunks/{6-CivW166X.js.map → 6-Cj4cg3MT.js.map} +1 -1
  47. package/build/server/chunks/{Logout-jfPnYBz7.js → Logout-CkwmxNTt.js} +2 -2
  48. package/build/server/chunks/{Logout-jfPnYBz7.js.map → Logout-CkwmxNTt.js.map} +1 -1
  49. package/build/server/chunks/{_page.svelte-D1Tk1-7i.js → _page.svelte-CVJoQAAB.js} +2 -2
  50. package/build/server/chunks/{_page.svelte-D1Tk1-7i.js.map → _page.svelte-CVJoQAAB.js.map} +1 -1
  51. package/build/server/chunks/{_page.svelte-CPmgKX2f.js → _page.svelte-D3kXcWlK.js} +2 -2
  52. package/build/server/chunks/{_page.svelte-CPmgKX2f.js.map → _page.svelte-D3kXcWlK.js.map} +1 -1
  53. package/build/server/chunks/{_page.svelte-C5KWK5D-.js → _page.svelte-DPdvFuWg.js} +3 -3
  54. package/build/server/chunks/{_page.svelte-C5KWK5D-.js.map → _page.svelte-DPdvFuWg.js.map} +1 -1
  55. package/build/server/chunks/{_page.svelte-BUYPMfbS.js → _page.svelte-whmO3TtB.js} +3 -3
  56. package/build/server/chunks/{_page.svelte-BUYPMfbS.js.map → _page.svelte-whmO3TtB.js.map} +1 -1
  57. package/build/server/chunks/user-DW-tjDe0.js +5656 -0
  58. package/build/server/chunks/user-DW-tjDe0.js.map +1 -0
  59. package/build/server/index.js +1 -1
  60. package/build/server/index.js.map +1 -1
  61. package/build/server/manifest.js +6 -6
  62. package/build/server/manifest.js.map +1 -1
  63. package/dist/acl.d.ts +54 -0
  64. package/dist/acl.js +63 -0
  65. package/dist/api/acl.d.ts +1 -0
  66. package/dist/api/acl.js +21 -0
  67. package/dist/api/passkeys.js +1 -1
  68. package/dist/api/register.js +1 -1
  69. package/dist/api/users.js +17 -13
  70. package/dist/auth.js +1 -0
  71. package/dist/cli.js +15 -9
  72. package/dist/database.d.ts +52 -7
  73. package/dist/database.js +147 -41
  74. package/dist/plugins.d.ts +10 -10
  75. package/dist/plugins.js +1 -1
  76. package/dist/requests.d.ts +1 -1
  77. package/dist/requests.js +1 -1
  78. package/dist/routes.d.ts +3 -0
  79. package/dist/routes.js +3 -0
  80. package/dist/sveltekit.js +1 -1
  81. package/package.json +2 -2
  82. package/svelte.config.js +3 -0
  83. package/web/lib/AccessControl.svelte +37 -0
  84. package/web/lib/AccessControlDialog.svelte +12 -0
  85. package/web/lib/Popover.svelte +0 -2
  86. package/web/lib/Upload.svelte +19 -21
  87. package/web/lib/WithContextMenu.svelte +0 -1
  88. package/build/client/_app/immutable/chunks/Ccv5p-Lr.js.br +0 -0
  89. package/build/client/_app/immutable/chunks/Ccv5p-Lr.js.gz +0 -0
  90. package/build/client/_app/immutable/chunks/DIqfHWch.js.br +0 -0
  91. package/build/client/_app/immutable/chunks/DIqfHWch.js.gz +0 -0
  92. package/build/client/_app/immutable/chunks/Dm7VIzXy.js.br +0 -0
  93. package/build/client/_app/immutable/chunks/Dm7VIzXy.js.gz +0 -0
  94. package/build/client/_app/immutable/chunks/iuOP1-8s.js +0 -33
  95. package/build/client/_app/immutable/chunks/iuOP1-8s.js.br +0 -0
  96. package/build/client/_app/immutable/chunks/iuOP1-8s.js.gz +0 -0
  97. package/build/client/_app/immutable/entry/app.CYeEqzuG.js.br +0 -0
  98. package/build/client/_app/immutable/entry/app.CYeEqzuG.js.gz +0 -0
  99. package/build/client/_app/immutable/entry/start.B8r-M4qY.js +0 -1
  100. package/build/client/_app/immutable/entry/start.B8r-M4qY.js.br +0 -2
  101. package/build/client/_app/immutable/entry/start.B8r-M4qY.js.gz +0 -0
  102. package/build/client/_app/immutable/nodes/1.BHYgH-pu.js.br +0 -0
  103. package/build/client/_app/immutable/nodes/1.BHYgH-pu.js.gz +0 -0
  104. package/build/client/_app/immutable/nodes/3.C6woCAgZ.js.br +0 -0
  105. package/build/client/_app/immutable/nodes/3.C6woCAgZ.js.gz +0 -0
  106. package/build/client/_app/immutable/nodes/4.CMRdSHhP.js.br +0 -0
  107. package/build/client/_app/immutable/nodes/4.CMRdSHhP.js.gz +0 -0
  108. package/build/client/_app/immutable/nodes/5.DQgmXUpj.js +0 -1
  109. package/build/client/_app/immutable/nodes/5.DQgmXUpj.js.br +0 -0
  110. package/build/client/_app/immutable/nodes/5.DQgmXUpj.js.gz +0 -0
  111. package/build/client/_app/immutable/nodes/6.asNffl6m.js.br +0 -0
  112. package/build/client/_app/immutable/nodes/6.asNffl6m.js.gz +0 -0
  113. package/build/server/chunks/user-C2RJxOZ2.js +0 -13552
  114. package/build/server/chunks/user-C2RJxOZ2.js.map +0 -1
  115. package/schema.json +0 -154
@@ -10,15 +10,15 @@ return {
10
10
  assets: new Set(["icons/brands.svg","icons/light.svg","icons/regular.svg","icons/solid.svg","styles.css"]),
11
11
  mimeTypes: {".svg":"image/svg+xml",".css":"text/css"},
12
12
  _: {
13
- client: {start:"_app/immutable/entry/start.B8r-M4qY.js",app:"_app/immutable/entry/app.CYeEqzuG.js",imports:["_app/immutable/entry/start.B8r-M4qY.js","_app/immutable/chunks/Ccv5p-Lr.js","_app/immutable/chunks/D5lcOOwR.js","_app/immutable/chunks/B3bf7yrh.js","_app/immutable/chunks/DCs3KlJy.js","_app/immutable/entry/app.CYeEqzuG.js","_app/immutable/chunks/B3bf7yrh.js","_app/immutable/chunks/D5lcOOwR.js","_app/immutable/chunks/DCs3KlJy.js","_app/immutable/chunks/DsnmJJEf.js","_app/immutable/chunks/ct9jA5hl.js"],stylesheets:[],fonts:[],uses_env_dynamic_public:false},
13
+ client: {start:"_app/immutable/entry/start.CkXOtoPI.js",app:"_app/immutable/entry/app.Bexu3pho.js",imports:["_app/immutable/entry/start.CkXOtoPI.js","_app/immutable/chunks/DQ-d8a5w.js","_app/immutable/chunks/D5lcOOwR.js","_app/immutable/chunks/B3bf7yrh.js","_app/immutable/chunks/DCs3KlJy.js","_app/immutable/entry/app.Bexu3pho.js","_app/immutable/chunks/B3bf7yrh.js","_app/immutable/chunks/D5lcOOwR.js","_app/immutable/chunks/DCs3KlJy.js","_app/immutable/chunks/DsnmJJEf.js","_app/immutable/chunks/ct9jA5hl.js"],stylesheets:[],fonts:[],uses_env_dynamic_public:false},
14
14
  nodes: [
15
15
  __memo(() => import('./chunks/0-CUfr8UwD.js')),
16
- __memo(() => import('./chunks/1-B46rUG8d.js')),
16
+ __memo(() => import('./chunks/1-Db3AncWW.js')),
17
17
  __memo(() => import('./chunks/2-c1bljkMr.js')),
18
- __memo(() => import('./chunks/3-CeRz1jLd.js')),
19
- __memo(() => import('./chunks/4-CPwP8Ikn.js')),
20
- __memo(() => import('./chunks/5-xNibYAp4.js')),
21
- __memo(() => import('./chunks/6-CivW166X.js'))
18
+ __memo(() => import('./chunks/3-BzEpIldk.js')),
19
+ __memo(() => import('./chunks/4-J7bxt5HT.js')),
20
+ __memo(() => import('./chunks/5-uwjgYAk8.js')),
21
+ __memo(() => import('./chunks/6-Cj4cg3MT.js'))
22
22
  ],
23
23
  routes: [
24
24
  {
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.js","sources":["../../.svelte-kit/adapter-node/manifest.js"],"sourcesContent":["export const manifest = (() => {\nfunction __memo(fn) {\n\tlet value;\n\treturn () => value ??= (value = fn());\n}\n\nreturn {\n\tappDir: \"_app\",\n\tappPath: \"_app\",\n\tassets: new Set([\"icons/brands.svg\",\"icons/light.svg\",\"icons/regular.svg\",\"icons/solid.svg\",\"styles.css\"]),\n\tmimeTypes: {\".svg\":\"image/svg+xml\",\".css\":\"text/css\"},\n\t_: {\n\t\tclient: {start:\"_app/immutable/entry/start.B8r-M4qY.js\",app:\"_app/immutable/entry/app.CYeEqzuG.js\",imports:[\"_app/immutable/entry/start.B8r-M4qY.js\",\"_app/immutable/chunks/Ccv5p-Lr.js\",\"_app/immutable/chunks/D5lcOOwR.js\",\"_app/immutable/chunks/B3bf7yrh.js\",\"_app/immutable/chunks/DCs3KlJy.js\",\"_app/immutable/entry/app.CYeEqzuG.js\",\"_app/immutable/chunks/B3bf7yrh.js\",\"_app/immutable/chunks/D5lcOOwR.js\",\"_app/immutable/chunks/DCs3KlJy.js\",\"_app/immutable/chunks/DsnmJJEf.js\",\"_app/immutable/chunks/ct9jA5hl.js\"],stylesheets:[],fonts:[],uses_env_dynamic_public:false},\n\t\tnodes: [\n\t\t\t__memo(() => import('./nodes/0.js')),\n\t\t\t__memo(() => import('./nodes/1.js')),\n\t\t\t__memo(() => import('./nodes/2.js')),\n\t\t\t__memo(() => import('./nodes/3.js')),\n\t\t\t__memo(() => import('./nodes/4.js')),\n\t\t\t__memo(() => import('./nodes/5.js')),\n\t\t\t__memo(() => import('./nodes/6.js'))\n\t\t],\n\t\troutes: [\n\t\t\t{\n\t\t\t\tid: \"/_axium/default\",\n\t\t\t\tpattern: /^\\/_axium\\/default\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 2 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/account\",\n\t\t\t\tpattern: /^\\/account\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 3 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/login\",\n\t\t\t\tpattern: /^\\/login\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 4 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/logout\",\n\t\t\t\tpattern: /^\\/logout\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 5 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/register\",\n\t\t\t\tpattern: /^\\/register\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 6 },\n\t\t\t\tendpoint: null\n\t\t\t}\n\t\t],\n\t\tprerendered_routes: new Set([]),\n\t\tmatchers: async () => {\n\t\t\t\n\t\t\treturn { };\n\t\t},\n\t\tserver_assets: {}\n\t}\n}\n})();\n\nexport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IAAI,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AAClD,IAAI,QAAQ,EAAE;AACd;AACA,GAAG;AACH,EAAE,kBAAkB,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC;AACjC,EAAE,QAAQ,EAAE,YAAY;AACxB;AACA,GAAG,OAAO,IAAI;AACd,EAAE,CAAC;AACH,EAAE,aAAa,EAAE;AACjB;AACA;AACA,CAAC;;AAEW,MAAC,WAAW,GAAG,IAAI,GAAG,CAAC,EAAE;;AAEzB,MAAC,IAAI,GAAG;;;;"}
1
+ {"version":3,"file":"manifest.js","sources":["../../.svelte-kit/adapter-node/manifest.js"],"sourcesContent":["export const manifest = (() => {\nfunction __memo(fn) {\n\tlet value;\n\treturn () => value ??= (value = fn());\n}\n\nreturn {\n\tappDir: \"_app\",\n\tappPath: \"_app\",\n\tassets: new Set([\"icons/brands.svg\",\"icons/light.svg\",\"icons/regular.svg\",\"icons/solid.svg\",\"styles.css\"]),\n\tmimeTypes: {\".svg\":\"image/svg+xml\",\".css\":\"text/css\"},\n\t_: {\n\t\tclient: {start:\"_app/immutable/entry/start.CkXOtoPI.js\",app:\"_app/immutable/entry/app.Bexu3pho.js\",imports:[\"_app/immutable/entry/start.CkXOtoPI.js\",\"_app/immutable/chunks/DQ-d8a5w.js\",\"_app/immutable/chunks/D5lcOOwR.js\",\"_app/immutable/chunks/B3bf7yrh.js\",\"_app/immutable/chunks/DCs3KlJy.js\",\"_app/immutable/entry/app.Bexu3pho.js\",\"_app/immutable/chunks/B3bf7yrh.js\",\"_app/immutable/chunks/D5lcOOwR.js\",\"_app/immutable/chunks/DCs3KlJy.js\",\"_app/immutable/chunks/DsnmJJEf.js\",\"_app/immutable/chunks/ct9jA5hl.js\"],stylesheets:[],fonts:[],uses_env_dynamic_public:false},\n\t\tnodes: [\n\t\t\t__memo(() => import('./nodes/0.js')),\n\t\t\t__memo(() => import('./nodes/1.js')),\n\t\t\t__memo(() => import('./nodes/2.js')),\n\t\t\t__memo(() => import('./nodes/3.js')),\n\t\t\t__memo(() => import('./nodes/4.js')),\n\t\t\t__memo(() => import('./nodes/5.js')),\n\t\t\t__memo(() => import('./nodes/6.js'))\n\t\t],\n\t\troutes: [\n\t\t\t{\n\t\t\t\tid: \"/_axium/default\",\n\t\t\t\tpattern: /^\\/_axium\\/default\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 2 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/account\",\n\t\t\t\tpattern: /^\\/account\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 3 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/login\",\n\t\t\t\tpattern: /^\\/login\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 4 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/logout\",\n\t\t\t\tpattern: /^\\/logout\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 5 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/register\",\n\t\t\t\tpattern: /^\\/register\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 6 },\n\t\t\t\tendpoint: null\n\t\t\t}\n\t\t],\n\t\tprerendered_routes: new Set([]),\n\t\tmatchers: async () => {\n\t\t\t\n\t\t\treturn { };\n\t\t},\n\t\tserver_assets: {}\n\t}\n}\n})();\n\nexport const prerendered = new Set([]);\n\nexport const base = \"\";"],"names":[],"mappings":"AAAY,MAAC,QAAQ,GAAG,CAAC,MAAM;AAC/B,SAAS,MAAM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,EAAE,CAAC,EAAE;AAClD,IAAI,QAAQ,EAAE;AACd;AACA,GAAG;AACH,EAAE,kBAAkB,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC;AACjC,EAAE,QAAQ,EAAE,YAAY;AACxB;AACA,GAAG,OAAO,IAAI;AACd,EAAE,CAAC;AACH,EAAE,aAAa,EAAE;AACjB;AACA;AACA,CAAC;;AAEW,MAAC,WAAW,GAAG,IAAI,GAAG,CAAC,EAAE;;AAEzB,MAAC,IAAI,GAAG;;;;"}
package/dist/acl.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ import type { AccessControl, Permission } from '@axium/core';
2
+ import type { ExpressionBuilder } from 'kysely';
3
+ import { type Selectable } from 'kysely';
4
+ import type { UserInternal } from './auth.js';
5
+ import * as db from './database.js';
6
+ interface AccessControllable {
7
+ userId: string;
8
+ publicPermission: Permission;
9
+ }
10
+ type _TableNames = (string & keyof db.Schema) & keyof {
11
+ [K in Exclude<keyof db.Schema, `acl.${string}`> as Selectable<db.Schema[K]> extends Omit<AccessControllable, 'acl'> ? K : never]: null;
12
+ };
13
+ /**
14
+ * `never` causes a ton of problems, so we use `string` if none of the tables are shareable.
15
+ */
16
+ export type AccessControllableTableName = _TableNames extends never ? keyof db.Schema : _TableNames;
17
+ export interface AccessControlInternal extends AccessControl {
18
+ user?: UserInternal;
19
+ }
20
+ export declare const ACLTypes: {
21
+ userId: {
22
+ type: string;
23
+ required: true;
24
+ };
25
+ createdAt: {
26
+ type: string;
27
+ required: true;
28
+ hasDefault: true;
29
+ };
30
+ itemId: {
31
+ type: string;
32
+ required: true;
33
+ };
34
+ permission: {
35
+ type: string;
36
+ required: true;
37
+ hasDefault: true;
38
+ };
39
+ };
40
+ /**
41
+ * Adds an Access Control List (ACL) in the database for managing access to rows in an existing table.
42
+ * @category Plugin API
43
+ */
44
+ export declare function createACL(table: AccessControllableTableName): Promise<void>;
45
+ export declare function dropACL(table: AccessControllableTableName): Promise<void>;
46
+ export declare function wipeACL(table: AccessControllableTableName): Promise<void>;
47
+ export declare function createEntry(itemType: AccessControllableTableName, data: Omit<AccessControl, 'createdAt'>): Promise<AccessControlInternal>;
48
+ export declare function deleteEntry(itemType: AccessControllableTableName, itemId: string, userId: string): Promise<void>;
49
+ /**
50
+ * Helper to select all shares for a given table, including the user information.
51
+ */
52
+ export declare function sharesFrom(table: AccessControllableTableName): (eb: ExpressionBuilder<db.Schema, any>) => import("kysely").AliasedRawBuilder<Required<AccessControl>[], "shares">;
53
+ export declare function getShares(itemType: AccessControllableTableName, itemId: string): Promise<Required<AccessControlInternal>[]>;
54
+ export {};
package/dist/acl.js ADDED
@@ -0,0 +1,63 @@
1
+ import { sql } from 'kysely';
2
+ import { jsonArrayFrom } from 'kysely/helpers/postgres';
3
+ import * as db from './database.js';
4
+ import * as io from './io.js';
5
+ const accessControllableTypes = {
6
+ userId: { type: 'uuid' },
7
+ publicPermission: { type: 'int4' },
8
+ };
9
+ export const ACLTypes = {
10
+ userId: { type: 'uuid', required: true },
11
+ createdAt: { type: 'timestamptz', required: true, hasDefault: true },
12
+ itemId: { type: 'uuid', required: true },
13
+ permission: { type: 'int4', required: true, hasDefault: true },
14
+ };
15
+ /**
16
+ * Adds an Access Control List (ACL) in the database for managing access to rows in an existing table.
17
+ * @category Plugin API
18
+ */
19
+ export async function createACL(table) {
20
+ await db.checkTableTypes(table, accessControllableTypes, { strict: true, extra: false });
21
+ io.start(`Creating table acl.${table}`);
22
+ await db.database.schema
23
+ .createTable(`acl.${table}`)
24
+ .addColumn('userId', 'uuid', col => col.references('users.id').onDelete('cascade'))
25
+ .addColumn('itemId', 'uuid', col => col.references(`${table}.id`).onDelete('cascade'))
26
+ .addPrimaryKeyConstraint('PK_acl_' + table, ['userId', 'itemId'])
27
+ .addColumn('createdAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
28
+ .addColumn('permission', 'integer', col => col.notNull().check(sql `permission >= 0 AND permission <= 5`))
29
+ .execute()
30
+ .then(io.done)
31
+ .catch(db.warnExists);
32
+ await db.createIndex(`acl.${table}`, 'userId');
33
+ await db.createIndex(`acl.${table}`, 'itemId');
34
+ }
35
+ export async function dropACL(table) {
36
+ io.start(`Dropping table acl.${table}`);
37
+ await db.database.schema.dropTable(`acl.${table}`).execute().then(io.done).catch(db.warnExists);
38
+ }
39
+ export async function wipeACL(table) {
40
+ io.start(`Wiping table acl.${table}`);
41
+ await db.database.deleteFrom(`acl.${table}`).execute().then(io.done).catch(db.warnExists);
42
+ }
43
+ export async function createEntry(itemType, data) {
44
+ return await db.database.insertInto(`acl.${itemType}`).values(data).returningAll().executeTakeFirstOrThrow();
45
+ }
46
+ export async function deleteEntry(itemType, itemId, userId) {
47
+ await db.database.deleteFrom(`acl.${itemType}`).where('itemId', '=', itemId).where('userId', '=', userId).execute();
48
+ }
49
+ /**
50
+ * Helper to select all shares for a given table, including the user information.
51
+ */
52
+ export function sharesFrom(table) {
53
+ return (eb) => jsonArrayFrom(eb
54
+ .selectFrom(`acl.${table} as _acl`)
55
+ .selectAll()
56
+ .select(db.userFromId)
57
+ .whereRef(`_acl.itemId`, '=', `${table}.id`))
58
+ .$castTo()
59
+ .as('shares');
60
+ }
61
+ export async function getShares(itemType, itemId) {
62
+ return await db.database.selectFrom(`acl.${itemType}`).where('itemId', '=', itemId).selectAll().select(db.userFromId).execute();
63
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import * as z from 'zod';
2
+ import { addRoute } from '../routes.js';
3
+ import { parseBody, withError } from '../requests.js';
4
+ import { createEntry } from '../acl.js';
5
+ addRoute({
6
+ path: '/api/acl/:itemType/:itemId',
7
+ params: {
8
+ itemType: z.string(),
9
+ itemId: z.uuid(),
10
+ },
11
+ async PUT(event) {
12
+ const type = event.params.itemType;
13
+ const itemId = event.params.itemId;
14
+ const data = await parseBody(event, z.object({
15
+ userId: z.uuid(),
16
+ permission: z.number().int().min(0).max(5),
17
+ }));
18
+ const share = await createEntry(type, { ...data, itemId }).catch(withError('Failed to create access control'));
19
+ return share;
20
+ },
21
+ });
@@ -1,7 +1,7 @@
1
1
  import { PasskeyChangeable } from '@axium/core/schemas';
2
2
  import { error } from '@sveltejs/kit';
3
3
  import { omit } from 'utilium';
4
- import z from 'zod';
4
+ import * as z from 'zod';
5
5
  import { getPasskey } from '../auth.js';
6
6
  import { database as db } from '../database.js';
7
7
  import { addRoute } from '../routes.js';
@@ -2,7 +2,7 @@ import { APIUserRegistration } from '@axium/core/schemas';
2
2
  import { generateRegistrationOptions, verifyRegistrationResponse } from '@simplewebauthn/server';
3
3
  import { error } from '@sveltejs/kit';
4
4
  import { randomUUID } from 'node:crypto';
5
- import z from 'zod';
5
+ import * as z from 'zod';
6
6
  import { createPasskey, getUser } from '../auth.js';
7
7
  import config from '../config.js';
8
8
  import { database as db } from '../database.js';
package/dist/api/users.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { LogoutSessions, PasskeyAuthenticationResponse, PasskeyRegistration, UserAuthOptions } from '@axium/core/schemas';
2
2
  import { UserChangeable } from '@axium/core/user';
3
- import { generateAuthenticationOptions, generateRegistrationOptions, verifyAuthenticationResponse, verifyRegistrationResponse, } from '@simplewebauthn/server';
3
+ import * as webauthn from '@simplewebauthn/server';
4
4
  import { error } from '@sveltejs/kit';
5
5
  import { omit, pick } from 'utilium';
6
- import z from 'zod';
7
- import { createPasskey, createVerification, getPasskey, getPasskeysByUserId, getSessions, getUser, useVerification, } from '../auth.js';
6
+ import * as z from 'zod';
7
+ import { createPasskey, createVerification, getPasskey, getPasskeysByUserId, getSessions, getUser, useVerification } from '../auth.js';
8
8
  import { config } from '../config.js';
9
9
  import { connect, database as db } from '../database.js';
10
- import { addRoute } from '../routes.js';
11
10
  import { checkAuth, createSessionData, parseBody, stripUser, withError } from '../requests.js';
11
+ import { addRoute } from '../routes.js';
12
12
  const challenges = new Map();
13
13
  const params = { id: z.uuid() };
14
14
  /**
@@ -33,9 +33,9 @@ addRoute({
33
33
  params,
34
34
  async GET(event) {
35
35
  const userId = event.params.id;
36
- const authed = await checkAuth(event, userId).catch(() => null);
37
- const user = authed?.user || (await getUser(userId).catch(withError('User does not exist', 404)));
38
- return stripUser(user, !!authed);
36
+ const auth = await checkAuth(event, userId).catch(() => null);
37
+ const user = auth?.user || (await getUser(userId).catch(withError('User does not exist', 404)));
38
+ return stripUser(user, !!auth);
39
39
  },
40
40
  async PATCH(event) {
41
41
  const userId = event.params.id;
@@ -87,7 +87,7 @@ addRoute({
87
87
  const passkeys = await getPasskeysByUserId(userId);
88
88
  if (!passkeys)
89
89
  error(409, { message: 'No passkeys exists for this user' });
90
- const options = await generateAuthenticationOptions({
90
+ const options = await webauthn.generateAuthenticationOptions({
91
91
  rpID: config.auth.rp_id,
92
92
  allowCredentials: passkeys.map(passkey => pick(passkey, 'id', 'transports')),
93
93
  });
@@ -105,13 +105,15 @@ addRoute({
105
105
  const passkey = await getPasskey(response.id).catch(withError('Passkey does not exist', 404));
106
106
  if (passkey.userId !== userId)
107
107
  error(403, { message: 'Passkey does not belong to this user' });
108
- const { verified } = await verifyAuthenticationResponse({
108
+ const { verified } = await webauthn
109
+ .verifyAuthenticationResponse({
109
110
  response,
110
111
  credential: passkey,
111
112
  expectedChallenge,
112
113
  expectedOrigin: config.auth.origin,
113
114
  expectedRPID: config.auth.rp_id,
114
- }).catch(withError('Verification failed', 400));
115
+ })
116
+ .catch(withError('Verification failed', 400));
115
117
  if (!verified)
116
118
  error(401, { message: 'Verification failed' });
117
119
  switch (type) {
@@ -136,7 +138,7 @@ addRoute({
136
138
  const userId = event.params.id;
137
139
  const existing = await getPasskeysByUserId(userId);
138
140
  const { user } = await checkAuth(event, userId);
139
- const options = await generateRegistrationOptions({
141
+ const options = await webauthn.generateRegistrationOptions({
140
142
  rpName: config.auth.rp_name,
141
143
  rpID: config.auth.rp_id,
142
144
  userName: userId,
@@ -172,11 +174,13 @@ addRoute({
172
174
  if (!expectedChallenge)
173
175
  error(404, { message: 'No registration challenge found for this user' });
174
176
  registrations.delete(userId);
175
- const { verified, registrationInfo } = await verifyRegistrationResponse({
177
+ const { verified, registrationInfo } = await webauthn
178
+ .verifyRegistrationResponse({
176
179
  response,
177
180
  expectedChallenge,
178
181
  expectedOrigin: config.auth.origin,
179
- }).catch(withError('Verification failed', 400));
182
+ })
183
+ .catch(withError('Verification failed', 400));
180
184
  if (!verified || !registrationInfo)
181
185
  error(401, { message: 'Verification failed' });
182
186
  const passkey = await createPasskey({
package/dist/auth.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { randomBytes, randomUUID } from 'node:crypto';
2
2
  import { connect, database as db, userFromId } from './database.js';
3
+ import { getToken } from './requests.js';
3
4
  export async function getUser(id) {
4
5
  connect();
5
6
  return await db.selectFrom('users').selectAll().where('id', '=', id).executeTakeFirstOrThrow();
package/dist/cli.js CHANGED
@@ -58,7 +58,7 @@ import { join } from 'node:path/posix';
58
58
  import { createInterface } from 'node:readline/promises';
59
59
  import { styleText } from 'node:util';
60
60
  import { getByString, isJSON, setByString } from 'utilium';
61
- import z from 'zod';
61
+ import * as z from 'zod';
62
62
  import $pkg from '../package.json' with { type: 'json' };
63
63
  import { apps } from './apps.js';
64
64
  import config, { configFiles, FileSchema, saveConfigTo } from './config.js';
@@ -105,6 +105,7 @@ const opts = {
105
105
  config.db.host = hostname || config.db.host;
106
106
  config.db.port = port && Number.isSafeInteger(parseInt(port)) ? parseInt(port) : config.db.port;
107
107
  }),
108
+ check: new Option('--check', 'check the database schema after initialization').default(false),
108
109
  force: new Option('-f, --force', 'force the operation').default(false),
109
110
  global: new Option('-g, --global', 'apply the operation globally').default(false),
110
111
  timeout: new Option('-t, --timeout <ms>', 'how long to wait for commands to complete.').default('1000').argParser(value => {
@@ -120,7 +121,9 @@ axiumDB
120
121
  .description('Initialize the database')
121
122
  .addOption(opts.force)
122
123
  .option('-s, --skip', 'If the user, database, or schema already exists, skip trying to create it.')
123
- .action(async (opt) => {
124
+ .addOption(opts.check)
125
+ .action(async (_localOpts, _) => {
126
+ const opt = _.optsWithGlobals();
124
127
  await db.init(opt).catch(handleError);
125
128
  });
126
129
  axiumDB
@@ -129,7 +132,7 @@ axiumDB
129
132
  .description('Check the status of the database')
130
133
  .action(async () => {
131
134
  try {
132
- console.log(await db.statusText());
135
+ console.log(await db.statText());
133
136
  }
134
137
  catch {
135
138
  output.error('Unavailable');
@@ -147,7 +150,7 @@ axiumDB
147
150
  const env_1 = { stack: [], error: void 0, hasError: false };
148
151
  try {
149
152
  const _ = __addDisposableResource(env_1, db.connect(), true);
150
- const stats = await db.status().catch(exit);
153
+ const stats = await db.count('users', 'passkeys', 'sessions').catch(exit);
151
154
  if (!opt.force)
152
155
  for (const key of ['users', 'passkeys', 'sessions']) {
153
156
  if (stats[key] == 0)
@@ -175,7 +178,7 @@ axiumDB
175
178
  const env_2 = { stack: [], error: void 0, hasError: false };
176
179
  try {
177
180
  const _ = __addDisposableResource(env_2, db.connect(), true);
178
- const stats = await db.status().catch(exit);
181
+ const stats = await db.count('users', 'passkeys', 'sessions').catch(exit);
179
182
  if (!opt.force)
180
183
  for (const key of ['users', 'passkeys', 'sessions']) {
181
184
  if (stats[key] == 0)
@@ -198,6 +201,7 @@ axiumDB
198
201
  axiumDB
199
202
  .command('check')
200
203
  .description('Check the structure of the database')
204
+ .option('-s, --strict', 'Throw errors instead of emitting warnings for most column problems')
201
205
  .action(async (opt) => {
202
206
  await db.check(opt).catch(exit);
203
207
  });
@@ -283,7 +287,7 @@ axiumConfig
283
287
  const schema = z.toJSONSchema(FileSchema, { io: 'input' });
284
288
  console.log(opt.json ? JSON.stringify(schema, configReplacer(opt), 4) : schema);
285
289
  });
286
- const axiumPlugin = program.command('plugins').description('Manage plugins').addOption(opts.global);
290
+ const axiumPlugin = program.command('plugin').alias('plugins').description('Manage plugins').addOption(opts.global);
287
291
  axiumPlugin
288
292
  .command('list')
289
293
  .alias('ls')
@@ -329,7 +333,7 @@ axiumPlugin
329
333
  exit(`Can't find a plugin matching "${search}"`);
330
334
  const specifier = getSpecifier(plugin);
331
335
  const _ = __addDisposableResource(env_4, db.connect(), true);
332
- await plugin.hooks.remove?.(opt, db.database);
336
+ await plugin.hooks.remove?.(opt);
333
337
  for (const [path, data] of configFiles) {
334
338
  if (!data.plugins)
335
339
  continue;
@@ -354,6 +358,7 @@ axiumPlugin
354
358
  .alias('install')
355
359
  .description('Initialize a plugin. This could include adding tables to the database or linking routes.')
356
360
  .addOption(opts.timeout)
361
+ .addOption(opts.check)
357
362
  .argument('<plugin>', 'the plugin to initialize')
358
363
  .action(async (search, opt) => {
359
364
  const env_5 = { stack: [], error: void 0, hasError: false };
@@ -362,7 +367,7 @@ axiumPlugin
362
367
  if (!plugin)
363
368
  exit(`Can't find a plugin matching "${search}"`);
364
369
  const _ = __addDisposableResource(env_5, db.connect(), true);
365
- await plugin.hooks.db_init?.({ force: false, ...opt, skip: true }, db.database);
370
+ await plugin.hooks.db_init?.({ force: false, ...opt, skip: true });
366
371
  }
367
372
  catch (e_5) {
368
373
  env_5.error = e_5;
@@ -568,7 +573,7 @@ program
568
573
  process.stdout.write(styleText('whiteBright', 'Database: '));
569
574
  const _ = __addDisposableResource(env_9, db.connect(), true);
570
575
  try {
571
- console.log(await db.statusText());
576
+ console.log(await db.statText());
572
577
  }
573
578
  catch {
574
579
  output.error('Unavailable');
@@ -607,6 +612,7 @@ program
607
612
  .description('Install Axium server')
608
613
  .addOption(opts.force)
609
614
  .addOption(opts.host)
615
+ .addOption(opts.check)
610
616
  .action(async (opt) => {
611
617
  await db.init({ ...opt, skip: opt.dbSkip }).catch(handleError);
612
618
  await restrictedPorts({ method: 'node-cap', action: 'enable' }).catch(handleError);
@@ -1,4 +1,4 @@
1
- import type { Preferences } from '@axium/core';
1
+ import type { Permission, Preferences } from '@axium/core';
2
2
  import type { AuthenticatorTransportFuture, CredentialDeviceType } from '@simplewebauthn/server';
3
3
  import type * as kysely from 'kysely';
4
4
  import { Kysely } from 'kysely';
@@ -41,37 +41,81 @@ export interface Schema {
41
41
  backedUp: boolean;
42
42
  transports: AuthenticatorTransportFuture[];
43
43
  };
44
+ [key: `acl.${string}`]: {
45
+ itemId: string;
46
+ userId: string;
47
+ createdAt: kysely.GeneratedAlways<Date>;
48
+ permission: Permission;
49
+ };
44
50
  }
45
51
  export type Database = Kysely<Schema> & AsyncDisposable;
46
52
  export declare let database: Database;
47
53
  export declare function connect(): Database;
48
- export declare function count<const T extends keyof Schema>(table: T): Promise<number>;
54
+ export declare function count<const TB extends keyof Schema>(...tables: TB[]): Promise<{
55
+ [K in TB]: number;
56
+ }>;
49
57
  export type TablesMatching<T> = (string & keyof Schema) & keyof {
50
58
  [K in keyof Schema as Schema[K] extends T ? K : never]: null;
51
59
  };
52
60
  /**
53
61
  * Select the user with the id from the userId column of a table, placing it in the `user` property.
54
62
  */
55
- export declare function userFromId(eb: kysely.ExpressionBuilder<Schema, any>): kysely.AliasedRawBuilder<UserInternal, 'user'>;
63
+ export declare function userFromId(eb: kysely.ExpressionBuilder<Schema, TablesMatching<{
64
+ userId: string;
65
+ }>>): kysely.AliasedRawBuilder<UserInternal, 'user'>;
56
66
  export interface Stats {
57
67
  users: number;
58
68
  passkeys: number;
59
69
  sessions: number;
60
70
  }
61
- export declare function status(): Promise<Stats>;
62
- export declare function statusText(): Promise<string>;
71
+ export declare function statText(): Promise<string>;
63
72
  export interface OpOptions {
64
- force: boolean;
73
+ force?: boolean;
65
74
  }
66
75
  export interface InitOptions extends OpOptions {
67
76
  skip: boolean;
77
+ check: boolean;
68
78
  }
69
79
  export declare function shouldRecreate(opt: InitOptions): boolean;
70
80
  export declare function getHBA(opt: OpOptions): Promise<[content: string, writeBack: (newContent: string) => void]>;
71
81
  /** Shortcut to output a warning if an error is thrown because relation already exists */
72
82
  export declare const warnExists: (error: string | Error) => void;
83
+ export declare function createIndex(table: string, column: string, mod?: (ib: kysely.CreateIndexBuilder<string>) => kysely.CreateIndexBuilder<string>): Promise<void>;
73
84
  export declare function init(opt: InitOptions): Promise<void>;
74
- export declare function check(opt: OpOptions): Promise<void>;
85
+ /**
86
+ * Expected column types for a table in the database.
87
+ */
88
+ export type ColumnTypes<TableSchema extends object> = {
89
+ [K in keyof TableSchema & string]: {
90
+ type: string;
91
+ required?: boolean;
92
+ hasDefault?: boolean;
93
+ };
94
+ };
95
+ type _Expected = {
96
+ [K in keyof Schema & string]: ColumnTypes<Schema[K]>;
97
+ };
98
+ export interface ExpectedSchema extends _Expected {
99
+ }
100
+ export declare const expectedTypes: ExpectedSchema;
101
+ export interface CheckOptions extends OpOptions {
102
+ /** Whether to throw an error instead of emitting a warning on most column issues */
103
+ strict?: boolean;
104
+ /**
105
+ * Memoized introspection table metadata.
106
+ * @internal @hidden
107
+ */
108
+ _metadata?: kysely.TableMetadata[];
109
+ /**
110
+ * Whether to check for extra columns.
111
+ */
112
+ extra?: boolean;
113
+ }
114
+ /**
115
+ * Checks that a table has the expected column types, nullability, and default values.
116
+ */
117
+ export declare function checkTableTypes<TB extends keyof Schema & string>(tableName: TB, types: ColumnTypes<Schema[TB]>, opt: CheckOptions): Promise<void>;
118
+ export declare function check(opt: CheckOptions): Promise<void>;
75
119
  export declare function clean(opt: Partial<OpOptions>): Promise<void>;
76
120
  /**
77
121
  * Completely remove Axium from the database.
@@ -82,3 +126,4 @@ export declare function uninstall(opt: OpOptions): Promise<void>;
82
126
  */
83
127
  export declare function wipe(opt: OpOptions): Promise<void>;
84
128
  export declare function rotatePassword(): Promise<void>;
129
+ export {};