@geekity/cms 0.42.1 → 0.42.2

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 (728) hide show
  1. package/dist/admin/admin-bar.d.ts +2 -3
  2. package/dist/admin/admin-bar.d.ts.map +1 -1
  3. package/dist/admin/admin-bar.js +4 -5
  4. package/dist/admin/admin-bar.js.map +1 -1
  5. package/dist/admin/app-activity.d.ts +1 -1
  6. package/dist/admin/appearance.d.ts +5 -5
  7. package/dist/admin/appearance.js +5 -5
  8. package/dist/admin/comments.d.ts +3 -3
  9. package/dist/admin/comments.js +2 -2
  10. package/dist/admin/comments.js.map +1 -1
  11. package/dist/admin/connected-apps.d.ts +1 -1
  12. package/dist/admin/connected-apps.js +1 -1
  13. package/dist/admin/credentials.d.ts +3 -3
  14. package/dist/admin/credentials.js +3 -3
  15. package/dist/admin/dashboard.js +2 -2
  16. package/dist/admin/dashboard.js.map +1 -1
  17. package/dist/admin/documents.d.ts +4 -4
  18. package/dist/admin/documents.d.ts.map +1 -1
  19. package/dist/admin/documents.js +150 -144
  20. package/dist/admin/documents.js.map +1 -1
  21. package/dist/admin/editor-actions.d.ts +1 -1
  22. package/dist/admin/editor-actions.js +1 -1
  23. package/dist/admin/federation.d.ts +11 -11
  24. package/dist/admin/federation.d.ts.map +1 -1
  25. package/dist/admin/federation.js +10 -10
  26. package/dist/admin/flash.d.ts +8 -0
  27. package/dist/admin/flash.d.ts.map +1 -1
  28. package/dist/admin/flash.js +11 -0
  29. package/dist/admin/flash.js.map +1 -1
  30. package/dist/admin/indieauth-consent.d.ts +1 -1
  31. package/dist/admin/indieauth-consent.js +1 -1
  32. package/dist/admin/legacy-migrations.d.ts +20 -19
  33. package/dist/admin/legacy-migrations.d.ts.map +1 -1
  34. package/dist/admin/legacy-migrations.js +14 -13
  35. package/dist/admin/legacy-migrations.js.map +1 -1
  36. package/dist/admin/media.js +1 -1
  37. package/dist/admin/menu.d.ts +1 -1
  38. package/dist/admin/menu.js +4 -4
  39. package/dist/admin/menu.js.map +1 -1
  40. package/dist/admin/messages.d.ts +2 -2
  41. package/dist/admin/messages.js +2 -2
  42. package/dist/admin/navigation.d.ts +3 -3
  43. package/dist/admin/navigation.js +3 -3
  44. package/dist/admin/personal-data.d.ts +1 -1
  45. package/dist/admin/personal-data.js +1 -1
  46. package/dist/admin/plugins.d.ts +1 -1
  47. package/dist/admin/plugins.js +1 -1
  48. package/dist/admin/preview.js +3 -3
  49. package/dist/admin/preview.js.map +1 -1
  50. package/dist/admin/recovery.d.ts +1 -1
  51. package/dist/admin/recovery.js +1 -1
  52. package/dist/admin/routes.d.ts +3 -3
  53. package/dist/admin/routes.js +14 -14
  54. package/dist/admin/routes.js.map +1 -1
  55. package/dist/admin/settings-discussion.d.ts +3 -3
  56. package/dist/admin/settings-discussion.js +3 -3
  57. package/dist/admin/settings-federation.d.ts +2 -2
  58. package/dist/admin/settings-federation.js +5 -5
  59. package/dist/admin/settings-federation.js.map +1 -1
  60. package/dist/admin/settings-general.d.ts +1 -1
  61. package/dist/admin/settings-general.js +2 -2
  62. package/dist/admin/settings-general.js.map +1 -1
  63. package/dist/admin/settings-page.d.ts +2 -2
  64. package/dist/admin/settings-page.js +1 -1
  65. package/dist/admin/settings-pages.d.ts +1 -1
  66. package/dist/admin/settings-pages.js +1 -1
  67. package/dist/admin/settings-reading.d.ts +2 -2
  68. package/dist/admin/settings-reading.js +2 -2
  69. package/dist/admin/syndication-targets.d.ts +2 -2
  70. package/dist/admin/syndication-targets.js +2 -2
  71. package/dist/admin/taxonomy.d.ts +4 -4
  72. package/dist/admin/taxonomy.js +4 -4
  73. package/dist/admin/templates.d.ts +2 -2
  74. package/dist/admin/templates.js +2 -2
  75. package/dist/admin/tools.d.ts +1 -1
  76. package/dist/admin/tools.js +1 -1
  77. package/dist/admin/users.d.ts +0 -159
  78. package/dist/admin/users.d.ts.map +1 -1
  79. package/dist/admin/users.js +204 -498
  80. package/dist/admin/users.js.map +1 -1
  81. package/dist/avatars/avatars.d.ts +2 -2
  82. package/dist/avatars/avatars.js +2 -2
  83. package/dist/cache.d.ts +1 -1
  84. package/dist/cache.js +1 -1
  85. package/dist/cli/args.d.ts +20 -0
  86. package/dist/cli/args.d.ts.map +1 -0
  87. package/dist/cli/args.js +138 -0
  88. package/dist/cli/args.js.map +1 -0
  89. package/dist/cli/commands.d.ts +10 -0
  90. package/dist/cli/commands.d.ts.map +1 -0
  91. package/dist/cli/commands.js +261 -0
  92. package/dist/cli/commands.js.map +1 -0
  93. package/dist/cli/database-in-use.d.ts +9 -0
  94. package/dist/cli/database-in-use.d.ts.map +1 -0
  95. package/dist/cli/database-in-use.js +38 -0
  96. package/dist/cli/database-in-use.js.map +1 -0
  97. package/dist/cli/dev-mode.d.ts +3 -0
  98. package/dist/cli/dev-mode.d.ts.map +1 -0
  99. package/dist/cli/dev-mode.js +31 -0
  100. package/dist/cli/dev-mode.js.map +1 -0
  101. package/dist/cli/export.d.ts +3 -0
  102. package/dist/cli/export.d.ts.map +1 -0
  103. package/dist/cli/export.js +53 -0
  104. package/dist/cli/export.js.map +1 -0
  105. package/dist/cli/format.d.ts +3 -0
  106. package/dist/cli/format.d.ts.map +1 -0
  107. package/dist/cli/format.js +10 -0
  108. package/dist/cli/format.js.map +1 -0
  109. package/dist/cli/gemini.d.ts +3 -0
  110. package/dist/cli/gemini.d.ts.map +1 -0
  111. package/dist/cli/gemini.js +34 -0
  112. package/dist/cli/gemini.js.map +1 -0
  113. package/dist/cli/help.d.ts +2 -0
  114. package/dist/cli/help.d.ts.map +1 -0
  115. package/dist/cli/help.js +111 -0
  116. package/dist/cli/help.js.map +1 -0
  117. package/dist/cli/import.d.ts +3 -0
  118. package/dist/cli/import.d.ts.map +1 -0
  119. package/dist/cli/import.js +84 -0
  120. package/dist/cli/import.js.map +1 -0
  121. package/dist/cli/init.d.ts +3 -0
  122. package/dist/cli/init.d.ts.map +1 -0
  123. package/dist/cli/init.js +21 -0
  124. package/dist/cli/init.js.map +1 -0
  125. package/dist/cli/maintenance.d.ts +3 -0
  126. package/dist/cli/maintenance.d.ts.map +1 -0
  127. package/dist/cli/maintenance.js +57 -0
  128. package/dist/cli/maintenance.js.map +1 -0
  129. package/dist/cli/options.d.ts +16 -0
  130. package/dist/cli/options.d.ts.map +1 -0
  131. package/dist/cli/options.js +27 -0
  132. package/dist/cli/options.js.map +1 -0
  133. package/dist/cli/password.d.ts +21 -0
  134. package/dist/cli/password.d.ts.map +1 -0
  135. package/dist/cli/password.js +52 -0
  136. package/dist/cli/password.js.map +1 -0
  137. package/dist/cli/plugin-commands.d.ts +11 -0
  138. package/dist/cli/plugin-commands.d.ts.map +1 -0
  139. package/dist/cli/plugin-commands.js +79 -0
  140. package/dist/cli/plugin-commands.js.map +1 -0
  141. package/dist/cli/plugin-folder.d.ts +3 -0
  142. package/dist/cli/plugin-folder.d.ts.map +1 -0
  143. package/dist/cli/plugin-folder.js +93 -0
  144. package/dist/cli/plugin-folder.js.map +1 -0
  145. package/dist/cli/rebuild.d.ts +5 -0
  146. package/dist/cli/rebuild.d.ts.map +1 -0
  147. package/dist/cli/rebuild.js +44 -0
  148. package/dist/cli/rebuild.js.map +1 -0
  149. package/dist/cli/resend.d.ts +3 -0
  150. package/dist/cli/resend.d.ts.map +1 -0
  151. package/dist/cli/resend.js +36 -0
  152. package/dist/cli/resend.js.map +1 -0
  153. package/dist/cli/run-job.d.ts +5 -0
  154. package/dist/cli/run-job.d.ts.map +1 -0
  155. package/dist/cli/run-job.js +29 -0
  156. package/dist/cli/run-job.js.map +1 -0
  157. package/dist/cli/serve.d.ts +3 -0
  158. package/dist/cli/serve.d.ts.map +1 -0
  159. package/dist/cli/serve.js +65 -0
  160. package/dist/cli/serve.js.map +1 -0
  161. package/dist/cli/settings.d.ts +5 -0
  162. package/dist/cli/settings.d.ts.map +1 -0
  163. package/dist/cli/settings.js +144 -0
  164. package/dist/cli/settings.js.map +1 -0
  165. package/dist/cli/site-plugins.d.ts +5 -0
  166. package/dist/cli/site-plugins.d.ts.map +1 -0
  167. package/dist/cli/site-plugins.js +7 -0
  168. package/dist/cli/site-plugins.js.map +1 -0
  169. package/dist/cli/strip-metadata.d.ts +3 -0
  170. package/dist/cli/strip-metadata.d.ts.map +1 -0
  171. package/dist/cli/strip-metadata.js +20 -0
  172. package/dist/cli/strip-metadata.js.map +1 -0
  173. package/dist/cli/sync.d.ts +3 -0
  174. package/dist/cli/sync.d.ts.map +1 -0
  175. package/dist/cli/sync.js +22 -0
  176. package/dist/cli/sync.js.map +1 -0
  177. package/dist/cli/user.d.ts +3 -0
  178. package/dist/cli/user.d.ts.map +1 -0
  179. package/dist/cli/user.js +54 -0
  180. package/dist/cli/user.js.map +1 -0
  181. package/dist/cli.d.ts +0 -62
  182. package/dist/cli.d.ts.map +1 -1
  183. package/dist/cli.js +6 -1566
  184. package/dist/cli.js.map +1 -1
  185. package/dist/cms/app.js +10 -10
  186. package/dist/cms/app.js.map +1 -1
  187. package/dist/cms/boot.js +5 -5
  188. package/dist/cms/boot.js.map +1 -1
  189. package/dist/cms/create.d.ts +17 -17
  190. package/dist/cms/create.d.ts.map +1 -1
  191. package/dist/cms/create.js +1 -1
  192. package/dist/cms/create.js.map +1 -1
  193. package/dist/cms/server-error.d.ts +1 -1
  194. package/dist/cms/server-error.js +1 -1
  195. package/dist/cms/services.js +14 -14
  196. package/dist/cms/services.js.map +1 -1
  197. package/dist/comments/akismet.d.ts +4 -4
  198. package/dist/comments/akismet.js +6 -6
  199. package/dist/comments/akismet.js.map +1 -1
  200. package/dist/comments/conversation.d.ts +29 -29
  201. package/dist/comments/conversation.d.ts.map +1 -1
  202. package/dist/comments/conversation.js +2 -2
  203. package/dist/comments/conversation.js.map +1 -1
  204. package/dist/comments/form.d.ts +3 -3
  205. package/dist/comments/form.d.ts.map +1 -1
  206. package/dist/comments/intake.d.ts +4 -4
  207. package/dist/comments/intake.d.ts.map +1 -1
  208. package/dist/comments/intake.js +1 -1
  209. package/dist/comments/migrations.d.ts +3 -3
  210. package/dist/comments/migrations.js +3 -3
  211. package/dist/comments/moderate.d.ts +2 -2
  212. package/dist/comments/moderate.js +2 -2
  213. package/dist/comments/page-form.d.ts +1 -1
  214. package/dist/comments/page-form.js +1 -1
  215. package/dist/comments/records.d.ts +9 -9
  216. package/dist/comments/records.d.ts.map +1 -1
  217. package/dist/comments/records.js +11 -10
  218. package/dist/comments/records.js.map +1 -1
  219. package/dist/comments/reply-notices.d.ts +2 -2
  220. package/dist/comments/reply-post.d.ts +2 -2
  221. package/dist/comments/submission.d.ts +8 -8
  222. package/dist/comments/submission.d.ts.map +1 -1
  223. package/dist/comments/submission.js +9 -9
  224. package/dist/comments/submission.js.map +1 -1
  225. package/dist/config.d.ts +27 -27
  226. package/dist/config.js +3 -3
  227. package/dist/contact/index.d.ts +1 -1
  228. package/dist/contact/index.js +1 -1
  229. package/dist/contact/records.d.ts +7 -7
  230. package/dist/contact/records.js +7 -7
  231. package/dist/content/alt-text.d.ts +2 -2
  232. package/dist/content/alt-text.js +2 -2
  233. package/dist/content/authors.d.ts +6 -6
  234. package/dist/content/authors.d.ts.map +1 -1
  235. package/dist/content/authors.js +6 -6
  236. package/dist/content/authors.js.map +1 -1
  237. package/dist/content/citation.d.ts +1 -1
  238. package/dist/content/content-tree.d.ts +5 -0
  239. package/dist/content/content-tree.d.ts.map +1 -0
  240. package/dist/content/content-tree.js +54 -0
  241. package/dist/content/content-tree.js.map +1 -0
  242. package/dist/content/content-watcher.d.ts +15 -0
  243. package/dist/content/content-watcher.d.ts.map +1 -0
  244. package/dist/content/content-watcher.js +104 -0
  245. package/dist/content/content-watcher.js.map +1 -0
  246. package/dist/content/document-form.d.ts +25 -24
  247. package/dist/content/document-form.d.ts.map +1 -1
  248. package/dist/content/document-form.js +7 -7
  249. package/dist/content/document-form.js.map +1 -1
  250. package/dist/content/document-kind.d.ts +6 -6
  251. package/dist/content/document.d.ts +1 -1
  252. package/dist/content/enclosure-form.js +1 -1
  253. package/dist/content/enclosure.js +1 -1
  254. package/dist/content/event-form.d.ts +2 -2
  255. package/dist/content/event.d.ts +3 -3
  256. package/dist/content/event.js +3 -3
  257. package/dist/content/guids.d.ts +6 -6
  258. package/dist/content/guids.d.ts.map +1 -1
  259. package/dist/content/guids.js +7 -7
  260. package/dist/content/guids.js.map +1 -1
  261. package/dist/content/handles.d.ts +1 -1
  262. package/dist/content/handles.js +1 -1
  263. package/dist/content/html-to-markdown.js +2 -2
  264. package/dist/content/language.d.ts +1 -1
  265. package/dist/content/language.js +1 -1
  266. package/dist/content/locale.d.ts +1 -1
  267. package/dist/content/locale.js +1 -1
  268. package/dist/content/markdown.d.ts +1 -1
  269. package/dist/content/markdown.js +1 -1
  270. package/dist/content/parser.d.ts +1 -1
  271. package/dist/content/parser.d.ts.map +1 -1
  272. package/dist/content/permalinks.d.ts +4 -4
  273. package/dist/content/permalinks.js +4 -4
  274. package/dist/content/photo-form.js +2 -2
  275. package/dist/content/photo.d.ts +2 -2
  276. package/dist/content/photo.js +1 -1
  277. package/dist/content/pinned.d.ts +3 -3
  278. package/dist/content/pinned.js +3 -3
  279. package/dist/content/post-fields.js +2 -2
  280. package/dist/content/post-fields.js.map +1 -1
  281. package/dist/content/post-type.d.ts +4 -4
  282. package/dist/content/post-type.js +1 -1
  283. package/dist/content/reconcile.d.ts +15 -0
  284. package/dist/content/reconcile.d.ts.map +1 -0
  285. package/dist/content/reconcile.js +106 -0
  286. package/dist/content/reconcile.js.map +1 -0
  287. package/dist/content/redirects.d.ts +2 -3
  288. package/dist/content/redirects.d.ts.map +1 -1
  289. package/dist/content/redirects.js +2 -3
  290. package/dist/content/redirects.js.map +1 -1
  291. package/dist/content/rsvp.d.ts +1 -1
  292. package/dist/content/rsvp.js +1 -1
  293. package/dist/content/sanitize.js +1 -1
  294. package/dist/content/save.d.ts +3 -3
  295. package/dist/content/save.js +4 -4
  296. package/dist/content/scan.d.ts +12 -0
  297. package/dist/content/scan.d.ts.map +1 -0
  298. package/dist/content/scan.js +58 -0
  299. package/dist/content/scan.js.map +1 -0
  300. package/dist/content/search.d.ts +3 -3
  301. package/dist/content/search.js +3 -3
  302. package/dist/content/served.d.ts +5 -5
  303. package/dist/content/served.js +4 -4
  304. package/dist/content/site-links.d.ts +3 -4
  305. package/dist/content/site-links.d.ts.map +1 -1
  306. package/dist/content/site-links.js +1 -2
  307. package/dist/content/site-links.js.map +1 -1
  308. package/dist/content/sqlite/clauses.d.ts +1 -1
  309. package/dist/content/sqlite/clauses.js +1 -1
  310. package/dist/content/sqlite/rows.d.ts +1 -1
  311. package/dist/content/sqlite/rows.js +1 -1
  312. package/dist/content/store.d.ts +26 -26
  313. package/dist/content/sync.d.ts +3 -3
  314. package/dist/content/sync.d.ts.map +1 -1
  315. package/dist/content/sync.js +65 -382
  316. package/dist/content/sync.js.map +1 -1
  317. package/dist/content/taxonomy.d.ts +9 -8
  318. package/dist/content/taxonomy.d.ts.map +1 -1
  319. package/dist/content/taxonomy.js +9 -8
  320. package/dist/content/taxonomy.js.map +1 -1
  321. package/dist/content/time.d.ts +1 -1
  322. package/dist/content/time.js +1 -1
  323. package/dist/content/trash.d.ts +4 -5
  324. package/dist/content/trash.d.ts.map +1 -1
  325. package/dist/content/trash.js +4 -5
  326. package/dist/content/trash.js.map +1 -1
  327. package/dist/content/write.d.ts +4 -4
  328. package/dist/content/write.js +19 -19
  329. package/dist/content/write.js.map +1 -1
  330. package/dist/drain.d.ts +1 -1
  331. package/dist/drain.js +1 -1
  332. package/dist/federation/actor.d.ts +9 -9
  333. package/dist/federation/actor.js +10 -10
  334. package/dist/federation/article.d.ts +14 -14
  335. package/dist/federation/article.js +27 -27
  336. package/dist/federation/article.js.map +1 -1
  337. package/dist/federation/backfill.d.ts +2 -2
  338. package/dist/federation/backfill.js +2 -2
  339. package/dist/federation/citations.d.ts +1 -1
  340. package/dist/federation/citations.js +1 -1
  341. package/dist/federation/cited-post.d.ts +1 -1
  342. package/dist/federation/cited-post.js +1 -1
  343. package/dist/federation/delivery-plan.d.ts +1 -1
  344. package/dist/federation/delivery.d.ts +3 -3
  345. package/dist/federation/delivery.d.ts.map +1 -1
  346. package/dist/federation/delivery.js +11 -12
  347. package/dist/federation/delivery.js.map +1 -1
  348. package/dist/federation/federation.d.ts +3 -3
  349. package/dist/federation/federation.d.ts.map +1 -1
  350. package/dist/federation/federation.js +7 -8
  351. package/dist/federation/federation.js.map +1 -1
  352. package/dist/federation/handles.d.ts +1 -1
  353. package/dist/federation/handles.js +1 -1
  354. package/dist/federation/inbox.d.ts +6 -6
  355. package/dist/federation/inbox.js +9 -9
  356. package/dist/federation/keys.d.ts +3 -3
  357. package/dist/federation/keys.js +3 -3
  358. package/dist/federation/object-ids.d.ts +1 -1
  359. package/dist/federation/paths.d.ts +8 -8
  360. package/dist/federation/paths.js +8 -8
  361. package/dist/federation/profiles.d.ts +2 -3
  362. package/dist/federation/profiles.d.ts.map +1 -1
  363. package/dist/federation/profiles.js +2 -3
  364. package/dist/federation/profiles.js.map +1 -1
  365. package/dist/federation/quotes.d.ts +1 -1
  366. package/dist/federation/records.d.ts +24 -24
  367. package/dist/federation/records.js +23 -23
  368. package/dist/federation/records.js.map +1 -1
  369. package/dist/federation/refusals.d.ts +1 -1
  370. package/dist/federation/relays.d.ts +1 -1
  371. package/dist/federation/relays.js +6 -6
  372. package/dist/federation/webfinger.d.ts +2 -2
  373. package/dist/federation/webfinger.js +2 -2
  374. package/dist/files/atomic.d.ts +2 -2
  375. package/dist/files/atomic.js +1 -1
  376. package/dist/forms/checker.d.ts +2 -2
  377. package/dist/forms/checker.d.ts.map +1 -1
  378. package/dist/forms/protection.d.ts +1 -1
  379. package/dist/forms/protection.js +1 -1
  380. package/dist/gemini/certificate.js +1 -1
  381. package/dist/images/markup.d.ts +2 -2
  382. package/dist/images/variants.d.ts +8 -8
  383. package/dist/images/variants.js +1 -1
  384. package/dist/indexnow.d.ts +1 -1
  385. package/dist/indieauth/grants.d.ts +2 -2
  386. package/dist/indieauth/identity.d.ts +3 -5
  387. package/dist/indieauth/identity.d.ts.map +1 -1
  388. package/dist/indieauth/identity.js +3 -5
  389. package/dist/indieauth/identity.js.map +1 -1
  390. package/dist/indieauth/redeem.d.ts +2 -2
  391. package/dist/indieauth/redeem.js +2 -2
  392. package/dist/indieauth/request.d.ts +2 -2
  393. package/dist/indieauth/request.js +2 -2
  394. package/dist/indieauth/tokens.d.ts +3 -5
  395. package/dist/indieauth/tokens.d.ts.map +1 -1
  396. package/dist/indieauth/tokens.js +3 -5
  397. package/dist/indieauth/tokens.js.map +1 -1
  398. package/dist/jobs/file-records.d.ts +1 -1
  399. package/dist/jobs/file-records.js +1 -1
  400. package/dist/jobs/in-process.d.ts +1 -1
  401. package/dist/jobs/in-process.js +1 -1
  402. package/dist/jobs/queue.d.ts +1 -1
  403. package/dist/jobs/queue.js +1 -1
  404. package/dist/mail/provider.d.ts +2 -2
  405. package/dist/mail/provider.js +2 -2
  406. package/dist/media/library.d.ts +2 -2
  407. package/dist/media/uploads.js +2 -2
  408. package/dist/media/uploads.js.map +1 -1
  409. package/dist/micropub/create.d.ts +1 -1
  410. package/dist/micropub/endpoint.d.ts +7 -7
  411. package/dist/micropub/endpoint.js +8 -8
  412. package/dist/micropub/endpoint.js.map +1 -1
  413. package/dist/micropub/media.d.ts +4 -4
  414. package/dist/micropub/media.js +4 -4
  415. package/dist/micropub/update.d.ts +1 -1
  416. package/dist/micropub/update.js +1 -1
  417. package/dist/notifications/comments.d.ts +1 -1
  418. package/dist/notifications/comments.js +2 -2
  419. package/dist/notifications/comments.js.map +1 -1
  420. package/dist/notifications/digest.d.ts +7 -7
  421. package/dist/notifications/digest.js +7 -7
  422. package/dist/notifications/mail-service.d.ts +4 -4
  423. package/dist/notifications/mail-service.d.ts.map +1 -1
  424. package/dist/notifications/mail-service.js +3 -3
  425. package/dist/notifications/mail-templates.d.ts +3 -3
  426. package/dist/notifications/optouts.d.ts +1 -1
  427. package/dist/notifications/optouts.js +1 -1
  428. package/dist/notifications/tokens.d.ts +2 -2
  429. package/dist/plugin.d.ts +5 -5
  430. package/dist/plugin.js +5 -5
  431. package/dist/plugins/changes.js +2 -2
  432. package/dist/plugins/folder.d.ts +2 -2
  433. package/dist/plugins/folder.js +2 -2
  434. package/dist/plugins/install.d.ts +1 -1
  435. package/dist/plugins/install.js +1 -1
  436. package/dist/plugins/registry.d.ts +1 -1
  437. package/dist/plugins/registry.js +1 -1
  438. package/dist/plugins/site.d.ts +1 -1
  439. package/dist/plugins/site.js +1 -1
  440. package/dist/privacy/erase.d.ts +1 -1
  441. package/dist/privacy/erase.js +1 -1
  442. package/dist/privacy/retention.d.ts +2 -2
  443. package/dist/privacy/retention.js +2 -2
  444. package/dist/site/admin-paths.d.ts +2 -2
  445. package/dist/site/admin-paths.js +2 -2
  446. package/dist/site/authors.d.ts +6 -6
  447. package/dist/site/authors.js +5 -5
  448. package/dist/site/dashboard-layout.d.ts +1 -1
  449. package/dist/site/indexnow-key.js +1 -1
  450. package/dist/site/namespace.d.ts +1 -1
  451. package/dist/site/namespace.js +1 -1
  452. package/dist/site/navigation.d.ts +10 -10
  453. package/dist/site/navigation.js +10 -10
  454. package/dist/site/notification-preferences.d.ts +3 -3
  455. package/dist/site/notification-preferences.js +2 -2
  456. package/dist/site/retention-policy.d.ts +1 -1
  457. package/dist/site/retention-policy.js +1 -1
  458. package/dist/site/users.d.ts +23 -24
  459. package/dist/site/users.d.ts.map +1 -1
  460. package/dist/site/users.js +6 -6
  461. package/dist/site/users.js.map +1 -1
  462. package/dist/store/admin-store.d.ts +2 -2
  463. package/dist/store/comments.d.ts +17 -17
  464. package/dist/store/comments.d.ts.map +1 -1
  465. package/dist/store/comments.js +14 -21
  466. package/dist/store/comments.js.map +1 -1
  467. package/dist/store/conversation.d.ts +2 -2
  468. package/dist/store/deliveries.d.ts +1 -1
  469. package/dist/store/deliveries.d.ts.map +1 -1
  470. package/dist/store/deliveries.js +10 -15
  471. package/dist/store/deliveries.js.map +1 -1
  472. package/dist/store/followers.d.ts +5 -5
  473. package/dist/store/followers.d.ts.map +1 -1
  474. package/dist/store/followers.js +7 -10
  475. package/dist/store/followers.js.map +1 -1
  476. package/dist/store/inbox-replies.d.ts +4 -4
  477. package/dist/store/inbox-replies.js +4 -4
  478. package/dist/store/inbox.d.ts +5 -5
  479. package/dist/store/inbox.d.ts.map +1 -1
  480. package/dist/store/inbox.js +21 -34
  481. package/dist/store/inbox.js.map +1 -1
  482. package/dist/store/profiles.d.ts +5 -5
  483. package/dist/store/profiles.d.ts.map +1 -1
  484. package/dist/store/profiles.js +4 -5
  485. package/dist/store/profiles.js.map +1 -1
  486. package/dist/store/relays.d.ts.map +1 -1
  487. package/dist/store/relays.js +7 -9
  488. package/dist/store/relays.js.map +1 -1
  489. package/dist/store/rows.d.ts +6 -20
  490. package/dist/store/rows.d.ts.map +1 -1
  491. package/dist/store/rows.js +10 -15
  492. package/dist/store/rows.js.map +1 -1
  493. package/dist/store/schema.js +35 -35
  494. package/dist/store/schema.js.map +1 -1
  495. package/dist/store/sessions.d.ts +1 -1
  496. package/dist/store/sessions.d.ts.map +1 -1
  497. package/dist/store/sessions.js +10 -10
  498. package/dist/store/sessions.js.map +1 -1
  499. package/dist/store/state.d.ts.map +1 -1
  500. package/dist/store/state.js +2 -2
  501. package/dist/store/state.js.map +1 -1
  502. package/dist/store/tokens.d.ts +1 -1
  503. package/dist/store/tokens.d.ts.map +1 -1
  504. package/dist/store/tokens.js +5 -5
  505. package/dist/store/tokens.js.map +1 -1
  506. package/dist/store/webmentions.d.ts +2 -2
  507. package/dist/store/webmentions.d.ts.map +1 -1
  508. package/dist/store/webmentions.js +11 -11
  509. package/dist/store/webmentions.js.map +1 -1
  510. package/dist/supervisor/plugin-watcher.d.ts +26 -0
  511. package/dist/supervisor/plugin-watcher.d.ts.map +1 -0
  512. package/dist/supervisor/plugin-watcher.js +90 -0
  513. package/dist/supervisor/plugin-watcher.js.map +1 -0
  514. package/dist/supervisor/primary.d.ts +4 -7
  515. package/dist/supervisor/primary.d.ts.map +1 -1
  516. package/dist/supervisor/primary.js +37 -94
  517. package/dist/supervisor/primary.js.map +1 -1
  518. package/dist/supervisor/protocol.d.ts +1 -1
  519. package/dist/supervisor/protocol.js +1 -1
  520. package/dist/supervisor/reload-queue.d.ts +10 -0
  521. package/dist/supervisor/reload-queue.d.ts.map +1 -0
  522. package/dist/supervisor/reload-queue.js +28 -0
  523. package/dist/supervisor/reload-queue.js.map +1 -0
  524. package/dist/supervisor/supervision.d.ts +2 -2
  525. package/dist/supervisor/supervision.js +2 -2
  526. package/dist/supervisor/worker.d.ts +1 -1
  527. package/dist/supervisor/worker.js +1 -1
  528. package/dist/theme/site-data.d.ts +3 -3
  529. package/dist/theme/site-data.js +2 -2
  530. package/dist/theme/templates.d.ts +3 -3
  531. package/dist/theme/templates.js +16 -16
  532. package/dist/theme/templates.js.map +1 -1
  533. package/dist/theme/themes.d.ts +11 -13
  534. package/dist/theme/themes.d.ts.map +1 -1
  535. package/dist/theme/themes.js +8 -9
  536. package/dist/theme/themes.js.map +1 -1
  537. package/dist/web/activity-folding.d.ts +33 -0
  538. package/dist/web/activity-folding.d.ts.map +1 -0
  539. package/dist/web/activity-folding.js +238 -0
  540. package/dist/web/activity-folding.js.map +1 -0
  541. package/dist/web/archive.d.ts +2 -3
  542. package/dist/web/archive.d.ts.map +1 -1
  543. package/dist/web/archive.js +2 -3
  544. package/dist/web/archive.js.map +1 -1
  545. package/dist/web/asset-routes.d.ts +1 -1
  546. package/dist/web/asset-routes.js +1 -1
  547. package/dist/web/comment-routes.js +2 -2
  548. package/dist/web/comment-routes.js.map +1 -1
  549. package/dist/web/compression.d.ts +1 -1
  550. package/dist/web/compression.js +1 -1
  551. package/dist/web/context.d.ts +21 -21
  552. package/dist/web/context.d.ts.map +1 -1
  553. package/dist/web/context.js +7 -7
  554. package/dist/web/conversation-context.d.ts +15 -0
  555. package/dist/web/conversation-context.d.ts.map +1 -0
  556. package/dist/web/conversation-context.js +2 -0
  557. package/dist/web/conversation-context.js.map +1 -0
  558. package/dist/web/conversation-feed.d.ts +18 -0
  559. package/dist/web/conversation-feed.d.ts.map +1 -0
  560. package/dist/web/conversation-feed.js +53 -0
  561. package/dist/web/conversation-feed.js.map +1 -0
  562. package/dist/web/conversation-gather.d.ts +12 -0
  563. package/dist/web/conversation-gather.d.ts.map +1 -0
  564. package/dist/web/conversation-gather.js +189 -0
  565. package/dist/web/conversation-gather.js.map +1 -0
  566. package/dist/web/conversation-lookup.d.ts +15 -0
  567. package/dist/web/conversation-lookup.d.ts.map +1 -0
  568. package/dist/web/conversation-lookup.js +101 -0
  569. package/dist/web/conversation-lookup.js.map +1 -0
  570. package/dist/web/conversation-threads.d.ts +12 -0
  571. package/dist/web/conversation-threads.d.ts.map +1 -0
  572. package/dist/web/conversation-threads.js +144 -0
  573. package/dist/web/conversation-threads.js.map +1 -0
  574. package/dist/web/conversation.d.ts +25 -61
  575. package/dist/web/conversation.d.ts.map +1 -1
  576. package/dist/web/conversation.js +14 -854
  577. package/dist/web/conversation.js.map +1 -1
  578. package/dist/web/document-page.js +4 -4
  579. package/dist/web/document-page.js.map +1 -1
  580. package/dist/web/document-render.d.ts +9 -0
  581. package/dist/web/document-render.d.ts.map +1 -0
  582. package/dist/web/document-render.js +130 -0
  583. package/dist/web/document-render.js.map +1 -0
  584. package/dist/web/document-site.d.ts +1 -1
  585. package/dist/web/document-site.d.ts.map +1 -1
  586. package/dist/web/document-site.js +1 -1
  587. package/dist/web/document-site.js.map +1 -1
  588. package/dist/web/env.d.ts +19 -19
  589. package/dist/web/env.d.ts.map +1 -1
  590. package/dist/web/federation-routes.d.ts +2 -2
  591. package/dist/web/federation-routes.d.ts.map +1 -1
  592. package/dist/web/federation-routes.js +22 -21
  593. package/dist/web/federation-routes.js.map +1 -1
  594. package/dist/web/feed-atom.d.ts +3 -3
  595. package/dist/web/feed-atom.js +3 -3
  596. package/dist/web/feed-item.d.ts +15 -16
  597. package/dist/web/feed-item.d.ts.map +1 -1
  598. package/dist/web/feed-item.js +1 -1
  599. package/dist/web/feed-item.js.map +1 -1
  600. package/dist/web/feed-json.d.ts +4 -4
  601. package/dist/web/feed-json.d.ts.map +1 -1
  602. package/dist/web/feed-json.js +2 -2
  603. package/dist/web/feed-routes.d.ts +3 -3
  604. package/dist/web/feed-routes.js +4 -4
  605. package/dist/web/feed-routes.js.map +1 -1
  606. package/dist/web/feed-rss.d.ts +2 -2
  607. package/dist/web/feed-rss.js +4 -4
  608. package/dist/web/feed-rss.js.map +1 -1
  609. package/dist/web/feed-source.d.ts +5 -5
  610. package/dist/web/feed-source.d.ts.map +1 -1
  611. package/dist/web/feed-source.js +2 -2
  612. package/dist/web/feed-source.js.map +1 -1
  613. package/dist/web/feed-xml.d.ts +4 -4
  614. package/dist/web/feed-xml.d.ts.map +1 -1
  615. package/dist/web/feed-xml.js +4 -4
  616. package/dist/web/feed-xml.js.map +1 -1
  617. package/dist/web/font-routes.d.ts +1 -1
  618. package/dist/web/font-routes.js +1 -1
  619. package/dist/web/health.d.ts +1 -1
  620. package/dist/web/index.d.ts +5 -3
  621. package/dist/web/index.d.ts.map +1 -1
  622. package/dist/web/index.js +4 -2
  623. package/dist/web/index.js.map +1 -1
  624. package/dist/web/indieauth-activity-log.js +1 -1
  625. package/dist/web/indieauth-bearer.d.ts +2 -2
  626. package/dist/web/indieauth-discovery.d.ts +12 -12
  627. package/dist/web/indieauth-discovery.d.ts.map +1 -1
  628. package/dist/web/indieauth-discovery.js +12 -12
  629. package/dist/web/indieauth-discovery.js.map +1 -1
  630. package/dist/web/indieauth-token.d.ts +2 -2
  631. package/dist/web/indieauth-token.js +2 -2
  632. package/dist/web/listing-render.d.ts +11 -0
  633. package/dist/web/listing-render.d.ts.map +1 -0
  634. package/dist/web/listing-render.js +76 -0
  635. package/dist/web/listing-render.js.map +1 -0
  636. package/dist/web/listing-subject.js +1 -1
  637. package/dist/web/listing-subject.js.map +1 -1
  638. package/dist/web/llms.d.ts +1 -1
  639. package/dist/web/llms.js +1 -1
  640. package/dist/web/maintenance.d.ts +1 -1
  641. package/dist/web/maintenance.js +1 -1
  642. package/dist/web/manifest.d.ts +1 -1
  643. package/dist/web/manifest.js +1 -1
  644. package/dist/web/markdown-chrome.d.ts +11 -0
  645. package/dist/web/markdown-chrome.d.ts.map +1 -0
  646. package/dist/web/markdown-chrome.js +178 -0
  647. package/dist/web/markdown-chrome.js.map +1 -0
  648. package/dist/web/markdown-conversation.d.ts +1 -1
  649. package/dist/web/markdown-conversation.d.ts.map +1 -1
  650. package/dist/web/markdown-environment.d.ts +10 -0
  651. package/dist/web/markdown-environment.d.ts.map +1 -0
  652. package/dist/web/markdown-environment.js +56 -0
  653. package/dist/web/markdown-environment.js.map +1 -0
  654. package/dist/web/markdown-representation.d.ts +1 -1
  655. package/dist/web/markdown-representation.d.ts.map +1 -1
  656. package/dist/web/markdown-representation.js +2 -2
  657. package/dist/web/markdown-representation.js.map +1 -1
  658. package/dist/web/negotiate.d.ts +5 -5
  659. package/dist/web/negotiate.d.ts.map +1 -1
  660. package/dist/web/negotiate.js +3 -3
  661. package/dist/web/negotiate.js.map +1 -1
  662. package/dist/web/oembed.d.ts +3 -3
  663. package/dist/web/oembed.js +3 -3
  664. package/dist/web/opensearch.d.ts +1 -1
  665. package/dist/web/opensearch.js +1 -1
  666. package/dist/web/page-context.d.ts +29 -0
  667. package/dist/web/page-context.d.ts.map +1 -0
  668. package/dist/web/page-context.js +126 -0
  669. package/dist/web/page-context.js.map +1 -0
  670. package/dist/web/page-tags.js +1 -1
  671. package/dist/web/page-tags.js.map +1 -1
  672. package/dist/web/paths.d.ts +1 -1
  673. package/dist/web/paths.js +3 -3
  674. package/dist/web/plugin-federation.d.ts +1 -1
  675. package/dist/web/plugin-federation.js +1 -1
  676. package/dist/web/render-scope.d.ts +20 -0
  677. package/dist/web/render-scope.d.ts.map +1 -0
  678. package/dist/web/render-scope.js +36 -0
  679. package/dist/web/render-scope.js.map +1 -0
  680. package/dist/web/render.d.ts +21 -363
  681. package/dist/web/render.d.ts.map +1 -1
  682. package/dist/web/render.js +46 -899
  683. package/dist/web/render.js.map +1 -1
  684. package/dist/web/request.d.ts +1 -1
  685. package/dist/web/request.js +1 -1
  686. package/dist/web/robots.d.ts +1 -1
  687. package/dist/web/robots.js +1 -1
  688. package/dist/web/routes.js +19 -19
  689. package/dist/web/routes.js.map +1 -1
  690. package/dist/web/search.d.ts +1 -1
  691. package/dist/web/search.js +1 -1
  692. package/dist/web/session.d.ts +8 -8
  693. package/dist/web/session.js +8 -8
  694. package/dist/web/share-image.d.ts +2 -3
  695. package/dist/web/share-image.d.ts.map +1 -1
  696. package/dist/web/share-image.js +1 -1
  697. package/dist/web/share-image.js.map +1 -1
  698. package/dist/web/site-view.d.ts +2 -2
  699. package/dist/web/status-pages.d.ts +1 -1
  700. package/dist/web/status-pages.d.ts.map +1 -1
  701. package/dist/web/theme-environment.d.ts +14 -0
  702. package/dist/web/theme-environment.d.ts.map +1 -0
  703. package/dist/web/theme-environment.js +112 -0
  704. package/dist/web/theme-environment.js.map +1 -0
  705. package/dist/web/theme-templates.d.ts +67 -0
  706. package/dist/web/theme-templates.d.ts.map +1 -0
  707. package/dist/web/theme-templates.js +65 -0
  708. package/dist/web/theme-templates.js.map +1 -0
  709. package/dist/webmention/microformats.d.ts +5 -5
  710. package/dist/webmention/microformats.d.ts.map +1 -1
  711. package/dist/webmention/receive.d.ts +7 -7
  712. package/dist/webmention/receive.d.ts.map +1 -1
  713. package/dist/webmention/receive.js +4 -4
  714. package/dist/webmention/receive.js.map +1 -1
  715. package/dist/webmention/reply-context/oembed.js +1 -1
  716. package/dist/webmention/reply-context.d.ts +10 -10
  717. package/dist/webmention/reply-context.d.ts.map +1 -1
  718. package/dist/webmention/reply-context.js +5 -5
  719. package/dist/webmention/reply-contexts.d.ts +6 -6
  720. package/dist/webmention/reply-contexts.d.ts.map +1 -1
  721. package/dist/webmention/reply-contexts.js +2 -2
  722. package/dist/webmention/service.d.ts +13 -13
  723. package/dist/webmention/service.js +9 -9
  724. package/dist/webmention/syndication.d.ts +6 -6
  725. package/dist/webmention/syndication.d.ts.map +1 -1
  726. package/dist/webmention/syndication.js +6 -6
  727. package/dist/webmention/syndication.js.map +1 -1
  728. package/package.json +2 -2
@@ -9,77 +9,27 @@ import { discardWritingLedger } from '../writing/ledger.js';
9
9
  import { stringOrEmpty } from '../util/forms.js';
10
10
  import { ADMIN_THEMES, adminTheme } from '../site/admin-theme.js';
11
11
  import { emailProblem, passwordProblem, usernameProblem } from './credentials.js';
12
- import { flash } from './flash.js';
12
+ import { flashAndRedirect } from './flash.js';
13
13
  import { editUserPath, USERS_PATH } from '../site/admin-paths.js';
14
14
  import { toldFollowers } from './settings-page.js';
15
15
  import { ADMIN_TEMPLATES } from './templates.js';
16
- /**
17
- * Where the add form lives, and where it posts.
18
- *
19
- * A screen of its own rather than a panel under the table, because the menu
20
- * says Users > Add new and a menu entry has to be somewhere to go. It is also
21
- * what keeps a refused add on a page about adding somebody instead of at the
22
- * top of a list of everybody.
23
- */
24
16
  export const ADD_USER_PATH = `${USERS_PATH}/new`;
25
- /**
26
- * The id in `/admin/users/<id>`, or `undefined` for a segment that is not one.
27
- *
28
- * Digits only, so `new`, `password` and the other named paths under
29
- * `/admin/users/` can never be read as somebody's id — and so a URL somebody
30
- * typed answers 404 rather than `NaN`.
31
- */
32
17
  function pathId(segment) {
33
18
  if (!/^\d+$/.test(segment))
34
19
  return undefined;
35
20
  return Number(segment);
36
21
  }
37
- /**
38
- * Users > Connected apps: the apps holding a token for whoever is signed in
39
- * (TASK-162). Mounted by `admin/connected-apps.ts`; named here so the
40
- * menu can link it without importing the IndieAuth side.
41
- */
42
22
  export const CONNECTED_APPS_PATH = `${USERS_PATH}/apps`;
43
- /** The child of Users the connected apps screen is. */
44
23
  export const CONNECTED_APPS_CHILD = 'apps';
45
- /**
46
- * Users > App activity: what apps sent to the IndieAuth and Micropub
47
- * endpoints, and what they were answered (TASK-221). Mounted by
48
- * `admin/app-activity.ts`; named here for the same reason as Connected apps.
49
- */
50
24
  export const APP_ACTIVITY_PATH = `${USERS_PATH}/activity`;
51
- /** The child of Users the app activity screen is. */
52
25
  export const APP_ACTIVITY_CHILD = 'activity';
53
- /** Where the signed-in admin's change-password form posts. */
54
26
  export const CHANGE_PASSWORD_PATH = `${USERS_PATH}/password`;
55
- /** Where a delete button posts, on the list or on the user's own screen. */
56
27
  export const DELETE_USER_PATH = `${USERS_PATH}/delete`;
57
- /** Where the email address on the Account panel posts. */
58
28
  export const USER_EMAIL_PATH = `${USERS_PATH}/email`;
59
- /**
60
- * Where the Profile panel posts.
61
- *
62
- * A path of its own rather than a second half of the email form, because the
63
- * two are about different audiences: an email address is private to the site
64
- * and a profile is the public face decision-14 puts at the author URL. One
65
- * form that saved both would mean an admin correcting a colleague's address
66
- * also republishing their bio.
67
- */
68
29
  export const USER_PROFILE_PATH = `${USERS_PATH}/profile`;
69
- /** Where the notice switches post. */
70
30
  export const USER_NOTIFICATIONS_PATH = `${USERS_PATH}/notifications`;
71
- /**
72
- * Where the how-often selects post.
73
- *
74
- * A path of its own rather than a second field on the switch, because the two
75
- * forms answer different questions and a switch is a button while a mode is a
76
- * select and a Save: one handler that had to work out which of the two it had
77
- * been given would be guessing at something the URL can simply say.
78
- */
79
31
  export const USER_NOTIFICATION_MODE_PATH = `${USER_NOTIFICATIONS_PATH}/mode`;
80
- /** Where the Theme panel posts; it sets the signed-in user's own theme and names nobody. */
81
32
  export const USER_THEME_PATH = `${USERS_PATH}/theme`;
82
- /** The fields the forms on these screens submit. */
83
33
  export const USER_FIELDS = {
84
34
  username: 'username',
85
35
  password: 'password',
@@ -89,349 +39,235 @@ export const USER_FIELDS = {
89
39
  newPassword: 'new_password',
90
40
  newPasswordConfirmation: 'new_password_confirmation',
91
41
  userId: 'user_id',
92
- /** Which notice a switch is about, by its name in the registry. */
93
42
  event: 'event',
94
- /**
95
- * Whether that notice is wanted.
96
- *
97
- * A checkbox, so a form that turns one off submits nothing at all under this
98
- * name — which is why the switch is a form of its own per event rather than
99
- * one form with a checkbox per event: a browser sends no field for an
100
- * unticked box, and one form could not tell "turned this off" from "did not
101
- * mention it".
102
- */
43
+ // A browser sends no field for an unticked box, so each event's switch is a
44
+ // form of its own.
103
45
  on: 'on',
104
- /** How often that notice should arrive, for an event that offers a choice. */
105
46
  mode: 'mode',
106
- /** The name to print instead of the login (TASK-67). */
107
47
  displayName: 'display_name',
108
- /** A few sentences about this person. */
109
48
  bio: 'bio',
110
- /** Their picture, as a path or a URL. */
111
49
  avatar: 'avatar',
112
- /** What they do, printed beside the name in a bio (TASK-79). */
113
50
  jobTitle: 'job_title',
114
- /** Where they are, as they write it. */
115
51
  location: 'location',
116
- /** Somewhere else they are: one `Label | URL` per line. */
117
52
  links: 'links',
118
- /** The admin's theme: a built-in DaisyUI theme's name, or empty to follow the system. */
119
53
  adminTheme: 'admin_theme',
120
54
  };
121
- /**
122
- * Register the users screens: the list, the add form, and one screen per user
123
- * where everything about that person is edited.
124
- *
125
- * The same split documents.ts makes (TASK-97). The table says who there is;
126
- * a person's own screen holds their email address, their public profile, what
127
- * they are emailed about, and — where the account can go — the delete. Every
128
- * save lands back on that screen, so it shows its own result.
129
- *
130
- * One thing is still only ever your own: the password. Changing somebody
131
- * else's is deliberately not offered — resetting a colleague's password from
132
- * under them is what `geekity user add` and a fresh account are for, and it
133
- * keeps the current-password check honest.
134
- */
135
55
  export function mountUsers(app, options) {
136
56
  const { render } = options;
137
- app.get(USERS_PATH, (c) => render(c, ADMIN_TEMPLATES.usersList, screen(c)));
138
- app.get(ADD_USER_PATH, (c) => render(c, ADMIN_TEMPLATES.usersNew, addScreen(c)));
139
- app.post(ADD_USER_PATH, async (c) => {
140
- const body = await c.req.parseBody();
141
- const username = stringOrEmpty(body[USER_FIELDS.username]).trim();
142
- const supplied = stringOrEmpty(body[USER_FIELDS.password]);
143
- const email = stringOrEmpty(body[USER_FIELDS.email]).trim();
144
- const generate = stringOrEmpty(body[USER_FIELDS.generate]) !== '';
145
- const password = generate ? generatePassword() : supplied;
146
- const problems = addUserProblems(username, password, generate, email);
147
- if (Object.keys(problems).length === 0) {
148
- try {
149
- await createUser({
150
- dataDir: c.var.config.dataDir,
151
- username,
152
- password,
153
- email,
154
- now: c.var.config.now(),
155
- });
156
- }
157
- catch (error) {
158
- if (!(error instanceof DuplicateUsernameError))
159
- throw error;
160
- problems.username = error.message;
161
- }
57
+ app.get(USERS_PATH, (c) => showUsers(c, render));
58
+ app.get(ADD_USER_PATH, (c) => showAddUser(c, render));
59
+ app.post(ADD_USER_PATH, (c) => addUser(c, render));
60
+ app.post(CHANGE_PASSWORD_PATH, (c) => changePassword(c, render));
61
+ app.post(USER_EMAIL_PATH, saveEmail);
62
+ app.post(USER_PROFILE_PATH, (c) => saveProfile(c, render));
63
+ app.post(USER_NOTIFICATIONS_PATH, saveNotification);
64
+ app.post(USER_NOTIFICATION_MODE_PATH, saveNotificationMode);
65
+ app.post(USER_THEME_PATH, saveTheme);
66
+ app.post(DELETE_USER_PATH, removeUser);
67
+ app.get(`${USERS_PATH}/:id`, (c) => showUser(c, render));
68
+ }
69
+ function showUsers(c, render) {
70
+ return render(c, ADMIN_TEMPLATES.usersList, screen(c));
71
+ }
72
+ function showAddUser(c, render) {
73
+ return render(c, ADMIN_TEMPLATES.usersNew, addScreen(c));
74
+ }
75
+ async function addUser(c, render) {
76
+ const body = await c.req.parseBody();
77
+ const username = stringOrEmpty(body[USER_FIELDS.username]).trim();
78
+ const supplied = stringOrEmpty(body[USER_FIELDS.password]);
79
+ const email = stringOrEmpty(body[USER_FIELDS.email]).trim();
80
+ const generate = stringOrEmpty(body[USER_FIELDS.generate]) !== '';
81
+ const password = generate ? generatePassword() : supplied;
82
+ const problems = addUserProblems(username, password, generate, email);
83
+ if (Object.keys(problems).length === 0) {
84
+ try {
85
+ await createUser({
86
+ dataDir: c.var.config.dataDir,
87
+ username,
88
+ password,
89
+ email,
90
+ now: c.var.config.now(),
91
+ });
162
92
  }
163
- if (Object.keys(problems).length > 0) {
164
- c.status(400);
165
- // Back onto the form that was refused, with what was typed still in it.
166
- return render(c, ADMIN_TEMPLATES.usersNew, addScreen(c, { addForm: { username, email, generate }, addProblems: problems }));
93
+ catch (error) {
94
+ if (!(error instanceof DuplicateUsernameError))
95
+ throw error;
96
+ problems.username = error.message;
167
97
  }
168
- // A generated password is shown once, here, and never stored in the clear.
169
- // The flash lives on the session row, so it is not in the URL, in a cookie
170
- // or in anybody's history.
171
- flash(c, 'notice', generate
172
- ? `Added ${username}. Their password is ${password} — copy it now, it is not shown again.`
173
- : `Added ${username}.`);
98
+ }
99
+ if (Object.keys(problems).length > 0) {
100
+ c.status(400);
101
+ return render(c, ADMIN_TEMPLATES.usersNew, addScreen(c, { addForm: { username, email, generate }, addProblems: problems }));
102
+ }
103
+ return flashAndRedirect(c, 'notice', generate
104
+ ? `Added ${username}. Their password is ${password} — copy it now, it is not shown again.`
105
+ : `Added ${username}.`, USERS_PATH);
106
+ }
107
+ async function changePassword(c, render) {
108
+ const session = c.var.session;
109
+ const user = signedInUser(c);
110
+ if (session === undefined || user === undefined)
174
111
  return c.redirect(USERS_PATH, 303);
112
+ const body = await c.req.parseBody();
113
+ const current = stringOrEmpty(body[USER_FIELDS.currentPassword]);
114
+ const next = stringOrEmpty(body[USER_FIELDS.newPassword]);
115
+ const confirmation = stringOrEmpty(body[USER_FIELDS.newPasswordConfirmation]);
116
+ const problems = changePasswordProblems({
117
+ correct: verifyUserPassword(c.var.config.dataDir, user.username, current) !== undefined,
118
+ next,
119
+ confirmation,
175
120
  });
176
- app.post(CHANGE_PASSWORD_PATH, async (c) => {
177
- // The guard has already established that there is a live session with a
178
- // user behind it, so both of these are present on every path that gets here.
179
- const session = c.var.session;
180
- const user = session?.userId === null || session === undefined
181
- ? undefined
182
- : findUserById(c.var.config.dataDir, session.userId);
183
- if (session === undefined || user === undefined)
184
- return c.redirect(USERS_PATH, 303);
185
- const body = await c.req.parseBody();
186
- const current = stringOrEmpty(body[USER_FIELDS.currentPassword]);
187
- const next = stringOrEmpty(body[USER_FIELDS.newPassword]);
188
- const confirmation = stringOrEmpty(body[USER_FIELDS.newPasswordConfirmation]);
189
- const problems = changePasswordProblems({
190
- correct: verifyUserPassword(c.var.config.dataDir, user.username, current) !== undefined,
191
- next,
192
- confirmation,
193
- });
194
- if (Object.keys(problems).length > 0) {
195
- c.status(400);
196
- // Back onto your own page, where the form is. Nothing that was typed is
197
- // echoed back: every field on this form is a password, and a password
198
- // does not belong in rendered HTML.
199
- return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, user, { passwordProblems: problems }));
200
- }
201
- await setUserPassword({ dataDir: c.var.config.dataDir, userId: user.id, password: next });
202
- // Every browser that was signed in as this user is signed out, because the
203
- // usual reason to change a password is that somebody else may have it. The
204
- // one doing the changing is spared, so the admin is not thrown out of the
205
- // form they just submitted.
206
- const ended = c.var.admin.deleteSessionsForUser(user.id, { except: session.id });
207
- flash(c, 'notice', ended === 0
208
- ? 'Your password was changed.'
209
- : `Your password was changed, and ${signedOut(ended)} signed out.`);
210
- return c.redirect(editUserPath(user.id), 303);
211
- });
212
- /**
213
- * Put an email address on a user, or take one off.
214
- *
215
- * Anybody's, not only your own. There is one role, so every user already has
216
- * every power there is — including deleting somebody and adding them back —
217
- * and a screen where an admin could see a colleague's address but not
218
- * correct a typo in it would be a rule with nothing behind it. It is also
219
- * what makes a site usable: an admin who has just added a colleague can put
220
- * their address in without waiting for them to sign in and do it.
221
- *
222
- * A flash and a redirect back to that person's screen rather than a 400 with
223
- * the form redrawn, unlike the two forms above: nothing here is a secret, so
224
- * there is no reason not to show the refusal beside the box it is about with
225
- * what is stored back in it.
226
- */
227
- app.post(USER_EMAIL_PATH, async (c) => {
228
- const named = await namedUser(c);
229
- if (named instanceof Response)
230
- return named;
231
- const { dataDir, body, target } = named;
232
- const email = stringOrEmpty(body[USER_FIELDS.email]).trim();
233
- const problem = emailProblem(email);
234
- if (problem !== undefined) {
235
- flash(c, 'error', problem);
236
- return c.redirect(editUserPath(target.id), 303);
237
- }
238
- await setUserEmail({ dataDir, userId: target.id, email });
239
- flash(c, 'notice', email === ''
240
- ? `${target.username} has no email address any more.`
241
- : `${target.username} will be emailed at ${email}.`);
242
- return c.redirect(editUserPath(target.id), 303);
243
- });
244
- /**
245
- * Write a user's public profile (TASK-67).
246
- *
247
- * Anybody's, for the reason the email field is anybody's: one role, and an
248
- * admin who has just added a colleague should be able to put a name and a
249
- * line about them on their archive without waiting for them to sign in. The
250
- * whole profile at once, because that is what the panel is — six boxes and
251
- * one Save — and a box somebody cleared is a field they no longer want.
252
- *
253
- * A flash and a redirect for everything but the Links box, because nothing
254
- * else here can be wrong enough to refuse. A link line that is not a link is
255
- * refused the way a menu line is (TASK-112): a 400 with the panel redrawn
256
- * around what was typed, because a link nobody can follow is worse stored
257
- * than reported, and because the line to fix has to still be there to fix.
258
- */
259
- app.post(USER_PROFILE_PATH, async (c) => {
260
- const named = await namedUser(c);
261
- if (named instanceof Response)
262
- return named;
263
- const { dataDir, body, target } = named;
264
- const typed = {
265
- displayName: stringOrEmpty(body[USER_FIELDS.displayName]),
266
- bio: stringOrEmpty(body[USER_FIELDS.bio]),
267
- avatar: stringOrEmpty(body[USER_FIELDS.avatar]),
268
- jobTitle: stringOrEmpty(body[USER_FIELDS.jobTitle]),
269
- location: stringOrEmpty(body[USER_FIELDS.location]),
270
- links: stringOrEmpty(body[USER_FIELDS.links]),
271
- };
272
- const problem = profileLinkLineProblem(typed.links);
273
- if (problem !== undefined) {
274
- c.status(400);
275
- // Every box comes back holding exactly what was typed into it, the way
276
- // the Navigation screen's does: a refused save that emptied the panel
277
- // would cost somebody their bio to report a bad link.
278
- return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, target, { profileProblems: { links: problem } }, typed));
279
- }
280
- const changed = await setUserProfile({
281
- dataDir,
282
- userId: target.id,
283
- profile: { ...typed, links: parseProfileLinks(typed.links) },
284
- });
285
- // The profile is the actor's profile now (decision-14), so saving it is
286
- // also an announcement: a follower's copy of somebody's name, bio and
287
- // picture is only as fresh as the last `Update` they were sent. The user
288
- // is read back rather than assumed, so the actor that goes out is built
289
- // from the file exactly as a peer fetching it would be.
290
- const saved = changed ? findUserById(dataDir, target.id) : undefined;
291
- const told = saved === undefined ? undefined : await c.var.delivery.updateActor(saved);
292
- flash(c, 'notice', `Saved ${target.username}’s profile.${toldFollowers(told)}`);
293
- return c.redirect(editUserPath(target.id), 303);
294
- });
295
- /**
296
- * Turn one notice on or off for one user.
297
- *
298
- * Anybody's, for the reason the email field is anybody's: one role, and an
299
- * admin who has just given a colleague an address should be able to say what
300
- * goes to it. An event nothing in this version knows is a no-op rather than an
301
- * error, because the only way to submit one is a form this CMS did not
302
- * render.
303
- */
304
- app.post(USER_NOTIFICATIONS_PATH, async (c) => {
305
- const named = await namedUser(c);
306
- if (named instanceof Response)
307
- return named;
308
- const { dataDir, body, target } = named;
309
- const name = stringOrEmpty(body[USER_FIELDS.event]);
310
- const event = notificationEvent(name);
311
- if (event === undefined) {
312
- flash(c, 'error', 'That is not something this site can tell anybody about.');
313
- return c.redirect(editUserPath(target.id), 303);
314
- }
315
- // An unticked checkbox submits no field at all, so its absence is the
316
- // answer rather than a missing one.
317
- const on = stringOrEmpty(body[USER_FIELDS.on]) !== '';
318
- await setUserNotification({ dataDir, userId: target.id, event: name, on });
319
- flash(c, 'notice', on
320
- ? `${target.username} will be emailed about ${event.label.toLowerCase()}.`
321
- : `${target.username} will not be emailed about ${event.label.toLowerCase()}.`);
322
- return c.redirect(editUserPath(target.id), 303);
323
- });
324
- /**
325
- * Say how often one notice reaches one user.
326
- *
327
- * Anybody's, for the reason the switch beside it is anybody's. A mode this
328
- * version does not know, or an event that offers no choice, changes nothing
329
- * and says so: the only way to submit either is a form this CMS did not
330
- * render.
331
- */
332
- app.post(USER_NOTIFICATION_MODE_PATH, async (c) => {
333
- const named = await namedUser(c);
334
- if (named instanceof Response)
335
- return named;
336
- const { dataDir, body, target } = named;
337
- const name = stringOrEmpty(body[USER_FIELDS.event]);
338
- const event = notificationEvent(name);
339
- if (event === undefined || !event.batched) {
340
- flash(c, 'error', 'That is not a notice this site can batch up.');
341
- return c.redirect(editUserPath(target.id), 303);
342
- }
343
- const wanted = deliveryMode(stringOrEmpty(body[USER_FIELDS.mode]));
344
- if (wanted === undefined) {
345
- flash(c, 'error', 'That is not one of the choices.');
346
- return c.redirect(editUserPath(target.id), 303);
347
- }
348
- await setUserNotificationMode({ dataDir, userId: target.id, event: name, mode: wanted });
349
- flash(c, 'notice', wanted === DEFAULT_DELIVERY_MODE
350
- ? `${target.username} will hear about ${event.label.toLowerCase()} as they arrive.`
351
- : `${target.username} will get one ${wanted === 'daily' ? 'daily' : 'hourly'} digest of ` +
352
- `${event.label.toLowerCase()}.`);
353
- return c.redirect(editUserPath(target.id), 303);
354
- });
355
- app.post(USER_THEME_PATH, async (c) => {
356
- const dataDir = c.var.config.dataDir;
357
- const userId = c.var.session?.userId;
358
- const user = userId == null ? undefined : findUserById(dataDir, userId);
359
- if (user === undefined)
360
- return c.redirect(USERS_PATH, 303);
361
- const body = await c.req.parseBody();
362
- const wanted = stringOrEmpty(body[USER_FIELDS.adminTheme]);
363
- const theme = adminTheme(wanted);
364
- if (wanted !== '' && theme === undefined) {
365
- flash(c, 'error', 'That is not one of the themes.');
366
- return c.redirect(editUserPath(user.id), 303);
367
- }
368
- await setUserAdminTheme({ dataDir, userId: user.id, theme });
369
- flash(c, 'notice', theme === undefined
370
- ? "The admin follows your system's light or dark setting."
371
- : `The admin is drawn in ${ADMIN_THEMES[theme].label} for you.`);
372
- return c.redirect(editUserPath(user.id), 303);
121
+ if (Object.keys(problems).length > 0) {
122
+ c.status(400);
123
+ return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, user, { passwordProblems: problems }));
124
+ }
125
+ await setUserPassword({ dataDir: c.var.config.dataDir, userId: user.id, password: next });
126
+ const ended = c.var.admin.deleteSessionsForUser(user.id, { except: session.id });
127
+ return backToUser(c, 'notice', ended === 0
128
+ ? 'Your password was changed.'
129
+ : `Your password was changed, and ${signedOut(ended)} signed out.`, user);
130
+ }
131
+ async function saveEmail(c) {
132
+ const named = await namedUser(c);
133
+ if (named instanceof Response)
134
+ return named;
135
+ const { dataDir, body, target } = named;
136
+ const email = stringOrEmpty(body[USER_FIELDS.email]).trim();
137
+ const problem = emailProblem(email);
138
+ if (problem !== undefined)
139
+ return backToUser(c, 'error', problem, target);
140
+ await setUserEmail({ dataDir, userId: target.id, email });
141
+ return backToUser(c, 'notice', email === ''
142
+ ? `${target.username} has no email address any more.`
143
+ : `${target.username} will be emailed at ${email}.`, target);
144
+ }
145
+ async function saveProfile(c, render) {
146
+ const named = await namedUser(c);
147
+ if (named instanceof Response)
148
+ return named;
149
+ const { dataDir, body, target } = named;
150
+ const typed = typedProfile(body);
151
+ const problem = profileLinkLineProblem(typed.links);
152
+ if (problem !== undefined) {
153
+ c.status(400);
154
+ return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, target, { profileProblems: { links: problem } }, typed));
155
+ }
156
+ const changed = await setUserProfile({
157
+ dataDir,
158
+ userId: target.id,
159
+ profile: { ...typed, links: parseProfileLinks(typed.links) },
373
160
  });
374
- app.post(DELETE_USER_PATH, async (c) => {
375
- const dataDir = c.var.config.dataDir;
376
- const body = await c.req.parseBody();
377
- const id = Number(stringOrEmpty(body[USER_FIELDS.userId]));
378
- const target = Number.isInteger(id) ? findUserById(dataDir, id) : undefined;
379
- const refusal = deleteUserRefusal({
380
- target,
381
- signedInAs: c.var.session?.userId ?? null,
382
- total: countUsers(dataDir),
383
- });
384
- if (refusal !== undefined) {
385
- flash(c, 'error', refusal);
386
- return c.redirect(USERS_PATH, 303);
387
- }
388
- await deleteUser({ dataDir, userId: target.id, now: c.var.config.now() });
389
- // Their sessions go with them. The foreign key that used to do this went
390
- // with the users table (decision-9), so it is done here — and a session
391
- // that outlives this one, in a database restored from a backup, is not a
392
- // login either: the guard refuses one whose user the file does not hold.
393
- c.var.admin.deleteSessionsForUser(target.id);
394
- flash(c, 'notice', `Deleted ${target.username}.`);
161
+ // A follower's copy of somebody's name, bio and picture is only as fresh as
162
+ // the last `Update` they were sent.
163
+ const saved = changed ? findUserById(dataDir, target.id) : undefined;
164
+ const told = saved === undefined ? undefined : await c.var.delivery.updateActor(saved);
165
+ return backToUser(c, 'notice', `Saved ${target.username}’s profile.${toldFollowers(told)}`, target);
166
+ }
167
+ function typedProfile(body) {
168
+ return {
169
+ displayName: stringOrEmpty(body[USER_FIELDS.displayName]),
170
+ bio: stringOrEmpty(body[USER_FIELDS.bio]),
171
+ avatar: stringOrEmpty(body[USER_FIELDS.avatar]),
172
+ jobTitle: stringOrEmpty(body[USER_FIELDS.jobTitle]),
173
+ location: stringOrEmpty(body[USER_FIELDS.location]),
174
+ links: stringOrEmpty(body[USER_FIELDS.links]),
175
+ };
176
+ }
177
+ async function saveNotification(c) {
178
+ const named = await namedUser(c);
179
+ if (named instanceof Response)
180
+ return named;
181
+ const { dataDir, body, target } = named;
182
+ const name = stringOrEmpty(body[USER_FIELDS.event]);
183
+ const event = notificationEvent(name);
184
+ if (event === undefined) {
185
+ return backToUser(c, 'error', 'That is not something this site can tell anybody about.', target);
186
+ }
187
+ // An unticked checkbox submits no field at all, so its absence is the
188
+ // answer rather than a missing one.
189
+ const on = stringOrEmpty(body[USER_FIELDS.on]) !== '';
190
+ await setUserNotification({ dataDir, userId: target.id, event: name, on });
191
+ return backToUser(c, 'notice', on
192
+ ? `${target.username} will be emailed about ${event.label.toLowerCase()}.`
193
+ : `${target.username} will not be emailed about ${event.label.toLowerCase()}.`, target);
194
+ }
195
+ async function saveNotificationMode(c) {
196
+ const named = await namedUser(c);
197
+ if (named instanceof Response)
198
+ return named;
199
+ const { dataDir, body, target } = named;
200
+ const name = stringOrEmpty(body[USER_FIELDS.event]);
201
+ const event = notificationEvent(name);
202
+ if (event === undefined || !event.batched) {
203
+ return backToUser(c, 'error', 'That is not a notice this site can batch up.', target);
204
+ }
205
+ const wanted = deliveryMode(stringOrEmpty(body[USER_FIELDS.mode]));
206
+ if (wanted === undefined)
207
+ return backToUser(c, 'error', 'That is not one of the choices.', target);
208
+ await setUserNotificationMode({ dataDir, userId: target.id, event: name, mode: wanted });
209
+ return backToUser(c, 'notice', wanted === DEFAULT_DELIVERY_MODE
210
+ ? `${target.username} will hear about ${event.label.toLowerCase()} as they arrive.`
211
+ : `${target.username} will get one ${wanted === 'daily' ? 'daily' : 'hourly'} digest of ` +
212
+ `${event.label.toLowerCase()}.`, target);
213
+ }
214
+ async function saveTheme(c) {
215
+ const user = signedInUser(c);
216
+ if (user === undefined)
395
217
  return c.redirect(USERS_PATH, 303);
218
+ const body = await c.req.parseBody();
219
+ const wanted = stringOrEmpty(body[USER_FIELDS.adminTheme]);
220
+ const theme = adminTheme(wanted);
221
+ if (wanted !== '' && theme === undefined) {
222
+ return backToUser(c, 'error', 'That is not one of the themes.', user);
223
+ }
224
+ await setUserAdminTheme({ dataDir: c.var.config.dataDir, userId: user.id, theme });
225
+ return backToUser(c, 'notice', theme === undefined
226
+ ? "The admin follows your system's light or dark setting."
227
+ : `The admin is drawn in ${ADMIN_THEMES[theme].label} for you.`, user);
228
+ }
229
+ async function removeUser(c) {
230
+ const dataDir = c.var.config.dataDir;
231
+ const target = userInForm(dataDir, await c.req.parseBody());
232
+ const refusal = deleteUserRefusal({
233
+ target,
234
+ signedInAs: c.var.session?.userId ?? null,
235
+ total: countUsers(dataDir),
396
236
  });
397
- /**
398
- * One user's screen (TASK-97).
399
- *
400
- * Registered last, after every named path under `/admin/users/`, and matched
401
- * only when the segment is digits — so Add new keeps its URL and a stray
402
- * `/admin/users/anything` is a 404 rather than a screen about nobody.
403
- */
404
- app.get(`${USERS_PATH}/:id`, (c) => {
405
- const id = pathId(c.req.param('id'));
406
- const user = id === undefined ? undefined : findUserById(c.var.config.dataDir, id);
407
- if (user === undefined)
408
- return c.notFound();
409
- return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, user));
410
- });
237
+ if (refusal !== undefined || target === undefined) {
238
+ return flashAndRedirect(c, 'error', refusal ?? GONE_USER, USERS_PATH);
239
+ }
240
+ await deleteUser({ dataDir, userId: target.id, now: c.var.config.now() });
241
+ c.var.admin.deleteSessionsForUser(target.id);
242
+ return flashAndRedirect(c, 'notice', `Deleted ${target.username}.`, USERS_PATH);
243
+ }
244
+ function showUser(c, render) {
245
+ const id = pathId(c.req.param('id') ?? '');
246
+ const user = id === undefined ? undefined : findUserById(c.var.config.dataDir, id);
247
+ if (user === undefined)
248
+ return c.notFound();
249
+ return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, user));
250
+ }
251
+ function backToUser(c, kind, message, user) {
252
+ return flashAndRedirect(c, kind, message, editUserPath(user.id));
253
+ }
254
+ function userInForm(dataDir, body) {
255
+ const id = Number(stringOrEmpty(body[USER_FIELDS.userId]));
256
+ return Number.isInteger(id) ? findUserById(dataDir, id) : undefined;
257
+ }
258
+ function signedInUser(c) {
259
+ const userId = c.var.session?.userId;
260
+ return userId == null ? undefined : findUserById(c.var.config.dataDir, userId);
411
261
  }
412
262
  async function namedUser(c) {
413
263
  const dataDir = c.var.config.dataDir;
414
264
  const body = await c.req.parseBody();
415
- const id = Number(stringOrEmpty(body[USER_FIELDS.userId]));
416
- const target = Number.isInteger(id) ? findUserById(dataDir, id) : undefined;
417
- if (target === undefined) {
418
- flash(c, 'error', GONE_USER);
419
- return c.redirect(USERS_PATH, 303);
420
- }
265
+ const target = userInForm(dataDir, body);
266
+ if (target === undefined)
267
+ return flashAndRedirect(c, 'error', GONE_USER, USERS_PATH);
421
268
  return { dataDir, body, target };
422
269
  }
423
270
  const GONE_USER = 'That user is already gone.';
424
- /**
425
- * Take a user out of the file. Returns `false` when there was nothing to take.
426
- *
427
- * Their IndieAuth tokens go with them (TASK-160): a token is a file in
428
- * `data/` too, so it is revoked here, where every caller deletes a user.
429
- *
430
- * Their sessions are not ended here: sessions are in the database, and the
431
- * screen that deletes a user ends them itself. A session that outlives this —
432
- * one in a database restored from a backup, say — names a user the file no
433
- * longer holds, and the admin guard turns that into no session at all.
434
- */
435
271
  export async function deleteUser(input) {
436
272
  const deleted = await removeUserRecord(input);
437
273
  await revokeTokensForUser(input.dataDir, input.userId, input.now);
@@ -439,15 +275,6 @@ export async function deleteUser(input) {
439
275
  discardWritingLedger(input.dataDir, input.userId);
440
276
  return deleted;
441
277
  }
442
- /**
443
- * Delete a user.
444
- *
445
- * Two refusals, in this order. The last remaining user cannot go, because a
446
- * site with no users falls back into first-run setup and anybody who reaches
447
- * it becomes its admin. And nobody may delete their own account: it would end
448
- * the session doing the deleting, and there is no undo. Both are a flash and a
449
- * redirect rather than a 400, because nothing was typed to send back.
450
- */
451
278
  export function deleteUserRefusal(input) {
452
279
  if (input.target === undefined)
453
280
  return GONE_USER;
@@ -459,12 +286,6 @@ export function deleteUserRefusal(input) {
459
286
  }
460
287
  return undefined;
461
288
  }
462
- /**
463
- * What is wrong with a proposed password change, one message per field.
464
- *
465
- * The current password is taken as already checked, rather than checked here,
466
- * so this stays a pure function over what the store said.
467
- */
468
289
  export function changePasswordProblems(input) {
469
290
  const problems = {};
470
291
  if (!input.correct)
@@ -477,20 +298,9 @@ export function changePasswordProblems(input) {
477
298
  }
478
299
  return problems;
479
300
  }
480
- /** "1 other session was" or "3 other sessions were", for the flash. */
481
301
  function signedOut(count) {
482
302
  return count === 1 ? '1 other session was' : `${String(count)} other sessions were`;
483
303
  }
484
- /**
485
- * What is wrong with a proposed user, one message per field.
486
- *
487
- * The rules are the shared ones, so an account made here is one
488
- * `/admin/setup` and `geekity user add` would both have accepted. A generated
489
- * password is not checked against them — it is made to satisfy them — and the
490
- * password field is not read at all when the box is ticked, so a stale value
491
- * left in it cannot be what is refused. An empty email is not a problem: it is
492
- * an optional field, and most users will never have one.
493
- */
494
304
  export function addUserProblems(username, password, generate = false, email = '') {
495
305
  const problems = {};
496
306
  const name = usernameProblem(username);
@@ -506,14 +316,8 @@ export function addUserProblems(username, password, generate = false, email = ''
506
316
  problems.email = address;
507
317
  return problems;
508
318
  }
509
- /**
510
- * The alphabet a generated password is drawn from: no `0`/`O` and no `1`/`l`,
511
- * because a generated password is read off a screen and typed somewhere else.
512
- */
513
319
  export const GENERATED_PASSWORD_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789';
514
- /** How many characters a generated password has. 20 is about 116 bits here. */
515
320
  export const GENERATED_PASSWORD_LENGTH = 20;
516
- /** A password nobody chose, from `randomInt` rather than `Math.random`. */
517
321
  export function generatePassword() {
518
322
  let password = '';
519
323
  for (let index = 0; index < GENERATED_PASSWORD_LENGTH; index += 1) {
@@ -521,37 +325,14 @@ export function generatePassword() {
521
325
  }
522
326
  return password;
523
327
  }
524
- /**
525
- * The Add new screen: the same context the listing is drawn from, rendered
526
- * through `pages/users/new.njk` instead. The two screens are the same chrome
527
- * around one of two things, and which of them it is is the route's business
528
- * rather than a flag the template has to read.
529
- */
530
328
  function addScreen(c, extra = {}) {
531
329
  return screen(c, { child: 'new', ...extra });
532
330
  }
533
- /**
534
- * Everything one user's screen renders (TASK-97).
535
- *
536
- * The same forms the table used to hold, one per panel and each with its
537
- * fields labelled: the account, the public profile, what this person is
538
- * emailed about, the password — only on your own page — and the delete, or the
539
- * sentence saying why this account cannot go.
540
- */
541
- function userScreen(c, user, extra = {},
542
- /**
543
- * What was typed into the Profile panel, where a save of it was refused: the
544
- * boxes are drawn holding this instead of what is stored, so the line to fix
545
- * is still on the screen and nothing else somebody wrote has been thrown
546
- * away (TASK-112).
547
- */
548
- typedProfile) {
331
+ function userScreen(c, user, extra = {}, typedProfile) {
549
332
  const signedInAs = c.var.session?.userId ?? null;
550
333
  const total = countUsers(c.var.config.dataDir);
551
334
  return {
552
335
  section: 'users',
553
- // The list's entry stays marked: an edit screen is where a row goes, not a
554
- // sixth thing in the menu.
555
336
  child: 'all',
556
337
  usersUrl: USERS_PATH,
557
338
  userProfileUrl: USER_PROFILE_PATH,
@@ -564,15 +345,10 @@ typedProfile) {
564
345
  userThemeUrl: USER_THEME_PATH,
565
346
  themeChoices: themeChoices(user),
566
347
  fields: USER_FIELDS,
567
- // `account` rather than `user`, which the chrome already holds: the bar
568
- // says who is signed in, and this screen is about somebody who may well be
569
- // anybody else.
570
348
  account: {
571
349
  ...row(user, { signedInAs, total }),
572
350
  ...(typedProfile === undefined ? {} : { profile: typedProfile }),
573
351
  },
574
- // Why this account cannot go, where it cannot, so the screen says it
575
- // instead of offering a button it is about to refuse.
576
352
  deleteRefusal: deleteUserRefusal({ target: user, signedInAs, total }),
577
353
  passwordProblems: {},
578
354
  profileProblems: {},
@@ -580,14 +356,6 @@ typedProfile) {
580
356
  ...extra,
581
357
  };
582
358
  }
583
- /**
584
- * Everything the users screens render: the listing, and the fields the add
585
- * form is drawn from.
586
- *
587
- * Nothing about editing a user is here any more (TASK-97). A row says who
588
- * somebody is and links to their screen; the only form in the table is the
589
- * delete, which is an action rather than a field.
590
- */
591
359
  function screen(c, extra = {}) {
592
360
  const signedInAs = c.var.session?.userId ?? null;
593
361
  const users = listUsers(c.var.config.dataDir);
@@ -614,42 +382,9 @@ function themeChoices(user) {
614
382
  })),
615
383
  ];
616
384
  }
617
- /**
618
- * A textarea of links as the list a profile stores: one per line, `Label |
619
- * URL`, or a bare URL that labels itself.
620
- *
621
- * A textarea rather than a repeating fieldset because a profile has two or
622
- * three links and a table row has no space for a widget; the separator is a
623
- * pipe because it is the one character nobody puts in a link label by
624
- * accident. Blank lines are skipped and the empties are dropped inside
625
- * `setUserProfile`, so a list somebody emptied leaves no key behind.
626
- */
627
385
  export function parseProfileLinks(value) {
628
386
  return profileLinkLines(value).map(profileLinkFields);
629
387
  }
630
- /**
631
- * What is wrong with a typed list of profile links, or `undefined` when
632
- * nothing is.
633
- *
634
- * The check the box never had (TASK-112). A URL goes through
635
- * {@link isLinkUrl}, the rule the Navigation screen's menu box already used,
636
- * so `Elsewhere | not a url` is refused in both places and for the same
637
- * reason. One message naming the first bad line, for the reason the menu box's
638
- * message names one: a box is fixed a line at a time, and the line to fix is
639
- * the useful half of the sentence.
640
- *
641
- * The same line as a menu item's, down to the `rel` values it may end in
642
- * (TASK-114): somebody who learns one box has learned the other, and a
643
- * trailing `| me` — the line that started all this — is a link rather than a
644
- * mistake. A profile link is published `rel="me"` either way, so typing it is
645
- * a no-op; typing `| me nofollow author` is three values on the rendered
646
- * attribute.
647
- *
648
- * Tolerant on the way out and strict on the way in: {@link parseProfileLinks}
649
- * and the file's own reader still take anything, so a link stored before this
650
- * check existed still renders and still comes back in the box. Refusing a save
651
- * is not refusing a read.
652
- */
653
388
  export function profileLinkLineProblem(value) {
654
389
  const bad = profileLinkLines(value).find((line) => !isProfileLink(profileLinkFields(line)));
655
390
  if (bad === undefined)
@@ -658,24 +393,12 @@ export function profileLinkLineProblem(value) {
658
393
  `per line, where the URL is ${LINK_URL_RULE}, and may end in ` +
659
394
  `${LINK_REL_RULE}. "${bad}" is not one.`);
660
395
  }
661
- /** The non-empty lines of the Links box, trimmed. A blank line asks for nothing. */
662
396
  function profileLinkLines(value) {
663
397
  return value
664
398
  .split('\n')
665
399
  .map((line) => line.trim())
666
400
  .filter((line) => line !== '');
667
401
  }
668
- /**
669
- * One typed line split where a profile link splits: its `rel` values off the
670
- * end, then at its first bar, so a label cannot hold one and a line with no
671
- * bar left is a URL that labels itself.
672
- *
673
- * The split alone, with nothing said about whether what came out is a link:
674
- * one spelling for the line the box reads back and the line it checks, so the
675
- * two can never disagree about which half is the URL. The tail comes off
676
- * through {@link splitLinkRel}, the same call the menu box makes, which is
677
- * what makes the two boxes one line format (TASK-114).
678
- */
679
402
  function profileLinkFields(line) {
680
403
  const { text, rel } = splitLinkRel(line);
681
404
  const carried = rel === '' ? {} : { rel };
@@ -684,11 +407,9 @@ function profileLinkFields(line) {
684
407
  return { label: text, href: text, ...carried };
685
408
  return { label: text.slice(0, bar).trim(), href: text.slice(bar + 1).trim(), ...carried };
686
409
  }
687
- /** Whether a split line is a link: somewhere to go, and something to call it. */
688
410
  function isProfileLink(link) {
689
411
  return link.label !== '' && isLinkUrl(link.href);
690
412
  }
691
- /** A stored list of links back as the textarea shows it. */
692
413
  export function formatProfileLinks(links) {
693
414
  return (links ?? [])
694
415
  .map((link) => {
@@ -697,18 +418,13 @@ export function formatProfileLinks(links) {
697
418
  })
698
419
  .join('\n');
699
420
  }
700
- /** One user, as the table lists them and as their own screen edits them. */
701
421
  function row(user, context) {
702
422
  const you = user.id === context.signedInAs;
703
423
  return {
704
424
  id: user.id,
705
425
  username: user.username,
706
426
  email: user.email ?? '',
707
- // Where the row goes, and where every save about this person lands.
708
427
  editUrl: editUserPath(user.id),
709
- // The public half of this person (TASK-67): what the archive at
710
- // `archiveUrl` is headed with, and — after TASK-68 — what their actor
711
- // carries.
712
428
  profile: {
713
429
  displayName: user.profile?.displayName ?? '',
714
430
  bio: user.profile?.bio ?? '',
@@ -718,20 +434,10 @@ function row(user, context) {
718
434
  links: formatProfileLinks(user.profile?.links),
719
435
  },
720
436
  archiveUrl: authorHref(user.username),
721
- // The id this person was published under before they were here (TASK-69).
722
- // Shown on their screen rather than edited: it is identity, not a
723
- // preference — the import writes it, or somebody editing
724
- // `data/users.json` does — and a box that let it be changed would be a box
725
- // that could break every follow this person has. Empty for almost
726
- // everybody, and then the screen says nothing about it at all.
727
437
  storedActorId: user.actorId ?? '',
728
- // One switch per registered event, so the screen loops rather than naming
729
- // the notices it happens to know about (TASK-55).
730
438
  notifications: notificationSwitches(user),
731
439
  createdAt: user.createdAt,
732
440
  you,
733
- // The button is rendered for everybody the signed-in admin may actually
734
- // delete, so neither screen offers an action it is about to refuse.
735
441
  deletable: !you && context.total > 1,
736
442
  };
737
443
  }