@jant/core 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/db/execute-file.js +1 -1
- package/bin/commands/db/export.js +1 -1
- package/bin/commands/migrate.js +4 -4
- package/bin/commands/posts/rebuild-html.js +1 -1
- package/bin/commands/reset-password.js +1 -1
- package/bin/commands/search/reindex.js +1 -1
- package/bin/commands/setup.js +4 -2
- package/bin/commands/site/export.js +3 -0
- package/bin/commands/site/import.js +178 -91
- package/bin/commands/site/pull-media.js +3 -2
- package/bin/commands/site/snapshot/export.js +3 -1
- package/bin/commands/site/snapshot/import.js +3 -2
- package/bin/commands/start.js +44 -0
- package/bin/commands/telegram/register-webhooks.js +1 -1
- package/bin/commands/uploads/cleanup.js +48 -9
- package/bin/jant.js +39 -4
- package/bin/lib/import-sources.js +151 -0
- package/bin/lib/node-env.js +14 -9
- package/bin/lib/runtime-target.js +1 -1
- package/bin/lib/site-pull-media.js +56 -4
- package/bin/lib/site-snapshot.js +39 -2
- package/bin/lib/sql-export.js +66 -10
- package/dist/{app-DIVtyB4m.js → app-jQI4OPRe.js} +5055 -4448
- package/dist/client/.vite/manifest.json +38 -38
- package/dist/client/_assets/chunks/{create-editor-B-m7X7S5.js → create-editor-5Y49x7h5.js} +2 -2
- package/dist/client/_assets/chunks/{footnote-rail-CmeoVtnU.js → footnote-rail-BJwswtVQ.js} +1 -1
- package/dist/client/_assets/chunks/{settings-paths-C-ZZBTau.js → settings-paths-h6RjIe3C.js} +2 -2
- package/dist/client/_assets/chunks/{slug-format-BcIsNKz-.js → slug-format-Dsi0e9Xn.js} +1 -1
- package/dist/client/_assets/chunks/{slugify-373citbs.js → slugify-DlHLyUHS.js} +1 -1
- package/dist/client/_assets/chunks/sortable-list-DYMcJrlS.js +2 -0
- package/dist/client/_assets/chunks/unsafe-svg-DxrzM_Gb.js +2 -0
- package/dist/client/_assets/client-52vQhZAv.js +296 -0
- package/dist/client/_assets/client-BaqmpPQ-.css +2 -0
- package/dist/client/_assets/{client-auth-BpkkKTsV.js → client-auth-BDcCR6u1.js} +2 -2
- package/dist/client/_assets/client-author-CGVvrNZ8.css +2 -0
- package/dist/client/_assets/{client-compose-C-DXzcFR.js → client-compose-CzEwT5qX.js} +4 -4
- package/dist/client/_assets/{client-manage-BfT7ht4M.js → client-manage-CF7x21L4.js} +37 -37
- package/dist/client/_assets/{client-settings-CGR_nZ78.js → client-settings-DIM44Zqh.js} +2 -2
- package/dist/{url-CKlGzvdN.js → constants-DEgyqWDl.js} +340 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +33 -1
- package/dist/node.js +57 -13
- package/package.json +13 -18
- package/src/__tests__/api-docs.test.ts +168 -1
- package/src/__tests__/bin/import-sources.test.ts +85 -0
- package/src/__tests__/bin/uploads-cleanup.test.ts +66 -26
- package/src/__tests__/cli-commands.test.ts +40 -0
- package/src/__tests__/config-docs.test.ts +119 -16
- package/src/__tests__/custom-url-redirects.test.ts +108 -0
- package/src/__tests__/export-collection-custom-urls.test.ts +69 -0
- package/src/__tests__/export-docs.test.ts +113 -41
- package/src/__tests__/export-feed-ids.test.ts +1 -0
- package/src/__tests__/export-format-version.test.ts +88 -0
- package/src/__tests__/export-hugo-build.test.ts +139 -4
- package/src/__tests__/export-import-roundtrip.test.ts +2 -1
- package/src/__tests__/export-service.test.ts +42 -13
- package/src/__tests__/export-smart-collection.test.ts +1 -1
- package/src/__tests__/feed-docs.test.ts +287 -21
- package/src/__tests__/feed-reply-addresses.test.ts +100 -0
- package/src/__tests__/feeds-disabled.test.ts +98 -0
- package/src/__tests__/fixtures/export-format/1.json +76 -0
- package/src/__tests__/fixtures/export-format/2.json +80 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2u5e5/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/faqyt/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/bought-too-many-lemons-again/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/city-walks/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/evf9j/_index.md +152 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/3zqv7/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/_index.md +39 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/j4v0q/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +57 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +46 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/data/jant.toml +124 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/_redirects +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/40bc6cd1f12e-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/meta.json +11 -0
- package/src/__tests__/helpers/app.ts +6 -1
- package/src/__tests__/helpers/export-fixtures.ts +1 -0
- package/src/__tests__/import-refused-aliases.test.ts +98 -0
- package/src/__tests__/import-site-command.test.ts +73 -8
- package/src/__tests__/public-types.test.ts +64 -0
- package/src/__tests__/release-fixtures.test.ts +79 -24
- package/src/__tests__/release-version.test.ts +84 -0
- package/src/__tests__/site-pull-media.test.ts +48 -0
- package/src/__tests__/snapshot-tables.test.ts +37 -0
- package/src/__tests__/sql-export.test.ts +21 -1
- package/src/__tests__/stored-file-headers.test.ts +94 -0
- package/src/__tests__/template-deploy-workflow.test.ts +101 -0
- package/src/__tests__/theme-docs.test.ts +113 -24
- package/src/__tests__/toolchain-versions.test.ts +54 -0
- package/src/__tests__/trailing-slash-redirect.test.ts +61 -0
- package/src/__tests__/vite-config-graph.test.ts +98 -0
- package/src/app.tsx +89 -66
- package/src/client/__tests__/compose-bridge-image-upload.test.ts +1 -0
- package/src/client/__tests__/compose-bridge.test.ts +87 -0
- package/src/client/__tests__/compose-shortcuts.test.ts +4 -4
- package/src/client/__tests__/footnote-rail.test.ts +1 -1
- package/src/client/__tests__/lazy-entries.test.ts +1 -1
- package/src/client/__tests__/media-scroll-hint.test.ts +2 -2
- package/src/client/avatar-upload.ts +10 -10
- package/src/client/components/__tests__/jant-compose-dialog.test.ts +295 -4
- package/src/client/components/__tests__/jant-compose-editor.test.ts +34 -0
- package/src/client/components/__tests__/jant-settings-general.test.ts +0 -32
- package/src/client/components/compose-types.ts +14 -0
- package/src/client/components/jant-compose-dialog.ts +96 -41
- package/src/client/components/jant-compose-editor.ts +21 -4
- package/src/client/components/jant-config-editor.ts +4 -6
- package/src/client/components/jant-media-lightbox.ts +4 -4
- package/src/client/components/jant-settings-general.ts +0 -4
- package/src/client/components/nav-manager-types.ts +6 -5
- package/src/client/compose-bridge.ts +15 -4
- package/src/client/compose-launch.ts +4 -6
- package/src/client/compose-shortcuts.ts +1 -1
- package/src/client/footnote-rail.ts +1 -1
- package/src/client/lazy-entries.ts +1 -1
- package/src/client/media-scroll-hint.ts +2 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +55 -0
- package/src/client/tiptap/markdown-clipboard.ts +50 -2
- package/src/client/upload-session.ts +7 -6
- package/src/db/__tests__/backfill-external-redirects.test.ts +59 -0
- package/src/db/__tests__/backfill-featured-discover.test.ts +56 -0
- package/src/db/backfills/0007_restore_external_redirect_scheme.sql +20 -0
- package/src/db/backfills/0008_turn_off_featured_only_discover.sql +11 -0
- package/src/i18n/locales/public/en.po +46 -48
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +45 -46
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +45 -46
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +15 -29
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +15 -29
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +15 -29
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/index.ts +43 -2
- package/src/lib/__tests__/api-settings.test.ts +3 -3
- package/src/lib/__tests__/constants.test.ts +10 -0
- package/src/lib/__tests__/discover.test.ts +8 -9
- package/src/lib/__tests__/env-values.test.ts +125 -0
- package/src/lib/__tests__/feed-path.test.ts +29 -0
- package/src/lib/__tests__/feed.test.ts +50 -22
- package/src/lib/__tests__/filter-dimensions.test.ts +22 -8
- package/src/lib/__tests__/post-list-cursor.test.ts +0 -10
- package/src/lib/__tests__/rate-limit.test.ts +22 -7
- package/src/lib/__tests__/resolve-config.test.ts +5 -3
- package/src/lib/__tests__/schemas.test.ts +72 -23
- package/src/lib/__tests__/slugify.test.ts +9 -0
- package/src/lib/__tests__/startup-config.test.ts +12 -0
- package/src/lib/__tests__/storage-s3.test.ts +214 -0
- package/src/lib/__tests__/theme.test.ts +20 -1
- package/src/lib/__tests__/time.test.ts +56 -0
- package/src/lib/__tests__/timeline.test.ts +46 -0
- package/src/lib/__tests__/url-fetch.test.ts +65 -1
- package/src/lib/__tests__/url.test.ts +60 -1
- package/src/lib/api-nav-items.ts +16 -20
- package/src/lib/api-post-input.ts +34 -1
- package/src/lib/api-posts.ts +125 -23
- package/src/lib/api-public-posts.ts +28 -37
- package/src/lib/api-search.ts +49 -2
- package/src/lib/api-settings.ts +159 -54
- package/src/lib/api-threads.ts +34 -11
- package/src/lib/constants.ts +6 -0
- package/src/lib/discover.ts +7 -23
- package/src/lib/env-values.ts +140 -0
- package/src/lib/env.ts +203 -12
- package/src/lib/feed-path.ts +8 -2
- package/src/lib/feed-policy.ts +110 -7
- package/src/lib/feed.ts +69 -25
- package/src/lib/filter-dimensions.ts +17 -10
- package/src/lib/github-sync-site-config.ts +1 -0
- package/src/lib/hugo-markdown.ts +5 -6
- package/src/lib/navigation.ts +4 -1
- package/src/lib/post-list-cursor.ts +33 -29
- package/src/lib/public-storage.ts +43 -0
- package/src/lib/rate-limit.ts +31 -16
- package/src/lib/render.tsx +5 -0
- package/src/lib/resolve-config.ts +16 -19
- package/src/lib/schemas.ts +248 -180
- package/src/lib/slugify.ts +6 -1
- package/src/lib/sse.ts +1 -1
- package/src/lib/startup-config.ts +20 -1
- package/src/lib/theme.ts +8 -5
- package/src/lib/thread-fold.ts +6 -0
- package/src/lib/thread-query.ts +19 -24
- package/src/lib/time.ts +137 -17
- package/src/lib/timeline.ts +56 -13
- package/src/lib/url-fetch.ts +141 -40
- package/src/lib/url.ts +86 -1
- package/src/middleware/__tests__/auth.test.ts +27 -0
- package/src/middleware/__tests__/cors.test.ts +54 -0
- package/src/middleware/__tests__/cross-origin.test.ts +149 -0
- package/src/middleware/__tests__/public-content-access.test.ts +2 -42
- package/src/middleware/auth.ts +34 -3
- package/src/middleware/cors.ts +4 -4
- package/src/middleware/cross-origin.ts +124 -0
- package/src/middleware/error-handler.ts +7 -0
- package/src/middleware/public-content-access.ts +3 -26
- package/src/middleware/secure-headers.ts +8 -2
- package/src/node/__tests__/cli-migrate.test.ts +2 -2
- package/src/node/__tests__/cli-runtime-target.test.ts +13 -2
- package/src/node/__tests__/cli-site-snapshot.test.ts +57 -0
- package/src/node/__tests__/cli-snapshot-meta.test.ts +11 -1
- package/src/node/__tests__/cli-sql-export.test.ts +25 -1
- package/src/node/__tests__/cli-start.test.ts +66 -0
- package/src/node/__tests__/request-handler.test.ts +37 -0
- package/src/node/__tests__/runtime.test.ts +56 -1
- package/src/node/request-handler.ts +58 -5
- package/src/node/runtime.ts +37 -11
- package/src/preset.css +3 -3
- package/src/routes/__tests__/compose.test.ts +84 -0
- package/src/routes/api/__tests__/collections.test.ts +68 -0
- package/src/routes/api/__tests__/mcp.test.ts +164 -9
- package/src/routes/api/__tests__/media.test.ts +9 -1
- package/src/routes/api/__tests__/nav-items.test.ts +27 -1
- package/src/routes/api/__tests__/posts.test.ts +269 -78
- package/src/routes/api/__tests__/search.test.ts +17 -4
- package/src/routes/api/__tests__/settings.test.ts +119 -85
- package/src/routes/api/__tests__/telegram.test.ts +11 -6
- package/src/routes/api/__tests__/threads.test.ts +11 -0
- package/src/routes/api/__tests__/upload-response.test.ts +48 -0
- package/src/routes/api/__tests__/uploads.test.ts +35 -2
- package/src/routes/api/collections.ts +3 -3
- package/src/routes/api/custom-urls.ts +2 -1
- package/src/routes/api/export.ts +1 -0
- package/src/routes/api/internal/__tests__/post-body-html.test.ts +19 -0
- package/src/routes/api/internal/__tests__/uploads.test.ts +2 -0
- package/src/routes/api/internal/sites.ts +16 -4
- package/src/routes/api/mcp.ts +1 -0
- package/src/routes/api/media.ts +7 -8
- package/src/routes/api/nav-items.ts +2 -1
- package/src/routes/api/posts.ts +18 -24
- package/src/routes/api/public/__tests__/posts.test.ts +15 -0
- package/src/routes/api/public/__tests__/threads-collections.test.ts +12 -45
- package/src/routes/api/public/__tests__/threads.test.ts +41 -9
- package/src/routes/api/public/posts.ts +2 -2
- package/src/routes/api/public/threads.ts +16 -26
- package/src/routes/api/search.ts +7 -41
- package/src/routes/api/settings.ts +32 -28
- package/src/routes/api/smart-collections.ts +6 -1
- package/src/routes/api/threads.ts +25 -26
- package/src/routes/api/upload.ts +6 -21
- package/src/routes/api/uploads.ts +14 -20
- package/src/routes/auth/__tests__/dev.test.ts +16 -13
- package/src/routes/auth/__tests__/hosted-sso.test.ts +51 -0
- package/src/routes/auth/__tests__/setup-auth.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-discover.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-flow.test.ts +32 -0
- package/src/routes/auth/__tests__/setup-rate-limit.test.ts +72 -0
- package/src/routes/auth/__tests__/setup-steps.test.ts +2 -0
- package/src/routes/auth/__tests__/signin.test.ts +167 -2
- package/src/routes/auth/dev.ts +4 -6
- package/src/routes/auth/hosted-sso.ts +9 -6
- package/src/routes/auth/setup.tsx +35 -5
- package/src/routes/auth/signin.tsx +96 -1
- package/src/routes/compose.tsx +47 -47
- package/src/routes/dash/__tests__/settings-avatar.test.ts +59 -4
- package/src/routes/dash/__tests__/settings-demo-locks.test.ts +147 -0
- package/src/routes/dash/custom-urls.tsx +2 -0
- package/src/routes/dash/settings.tsx +79 -32
- package/src/routes/feed/__tests__/feed.test.ts +93 -3
- package/src/routes/feed/__tests__/sitemap.test.ts +42 -0
- package/src/routes/feed/feed.ts +128 -175
- package/src/routes/feed/sitemap.ts +9 -7
- package/src/routes/pages/__tests__/archive-years.test.ts +45 -0
- package/src/routes/pages/__tests__/collection-routing.test.ts +40 -0
- package/src/routes/pages/__tests__/collections.test.ts +3 -0
- package/src/routes/pages/__tests__/language-routing.test.ts +31 -0
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +34 -2
- package/src/routes/pages/__tests__/search.test.ts +5 -2
- package/src/routes/pages/__tests__/thread-gap.test.ts +207 -0
- package/src/routes/pages/archive.tsx +33 -94
- package/src/routes/pages/brand.tsx +1 -0
- package/src/routes/pages/collection.tsx +13 -84
- package/src/routes/pages/collections.tsx +2 -0
- package/src/routes/pages/featured.tsx +7 -2
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/latest.tsx +6 -2
- package/src/routes/pages/new.tsx +1 -0
- package/src/routes/pages/page.tsx +73 -47
- package/src/routes/pages/search.tsx +5 -3
- package/src/routes/pages/smart-collection.tsx +11 -70
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/pages/theme-sample.tsx +1 -0
- package/src/runtime/__tests__/readiness.test.ts +16 -0
- package/src/runtime/cloudflare.ts +2 -3
- package/src/runtime/index.ts +3 -1
- package/src/runtime/node.ts +3 -5
- package/src/runtime/readiness.ts +5 -0
- package/src/services/__tests__/auth.test.ts +115 -0
- package/src/services/__tests__/collection.test.ts +9 -0
- package/src/services/__tests__/github-sync-webhook.test.ts +78 -0
- package/src/services/__tests__/hosted-handoff.test.ts +208 -1
- package/src/services/__tests__/media.test.ts +47 -27
- package/src/services/__tests__/navigation.test.ts +67 -15
- package/src/services/__tests__/post.test.ts +103 -56
- package/src/services/__tests__/search.test.ts +38 -0
- package/src/services/__tests__/settings.test.ts +2 -14
- package/src/services/__tests__/smart-collection.test.ts +2 -2
- package/src/services/__tests__/telegram-ingest.test.ts +113 -0
- package/src/services/__tests__/thread.test.ts +26 -11
- package/src/services/auth.ts +36 -4
- package/src/services/collection.ts +46 -5
- package/src/services/custom-url.ts +11 -4
- package/src/services/export-theme/assets/client-site.css +1 -1
- package/src/services/export-theme/assets/client-site.js +2 -2
- package/src/services/export-theme/layouts/_default/baseof.html +1 -1
- package/src/services/export-theme/layouts/collection/single.html +1 -1
- package/src/services/export-theme/layouts/partials/featured-thread.html +8 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/media-gallery.html +6 -3
- package/src/services/export-theme/layouts/smart_collection/list.html +1 -1
- package/src/services/export-theme/styles/main.css +3 -3
- package/src/services/export.ts +68 -19
- package/src/services/github-sync.ts +10 -10
- package/src/services/hosted-handoff.ts +106 -6
- package/src/services/index.ts +3 -1
- package/src/services/language.ts +33 -0
- package/src/services/mcp.ts +176 -438
- package/src/services/media.ts +69 -21
- package/src/services/navigation.ts +19 -4
- package/src/services/path.ts +45 -3
- package/src/services/post.ts +329 -214
- package/src/services/search.ts +22 -3
- package/src/services/settings.ts +36 -3
- package/src/services/site-admin.ts +1 -0
- package/src/services/smart-collection.ts +10 -3
- package/src/services/telegram.ts +23 -6
- package/src/services/thread.ts +11 -3
- package/src/services/upload-session.ts +14 -15
- package/src/styles/components.css +2 -2
- package/src/styles/site-media.css +2 -2
- package/src/styles/tokens.css +19 -22
- package/src/styles/ui-author.css +73 -94
- package/src/styles/ui.css +62 -62
- package/src/types/app-context.ts +5 -1
- package/src/types/bindings.ts +11 -0
- package/src/types/config.ts +4 -4
- package/src/types/constants.ts +20 -0
- package/src/types/props.ts +34 -8
- package/src/types/views.ts +28 -13
- package/src/ui/color-themes.ts +6 -5
- package/src/ui/dash/settings/GeneralContent.tsx +0 -22
- package/src/ui/dash/settings/__tests__/GeneralContent.test.tsx +0 -21
- package/src/ui/feed/CuratedThreadPreview.tsx +7 -2
- package/src/ui/feed/LinkCard.tsx +1 -2
- package/src/ui/feed/NoteCard.tsx +1 -2
- package/src/ui/feed/QuoteCard.tsx +2 -2
- package/src/ui/feed/ThreadPreview.tsx +6 -6
- package/src/ui/feed/TimelineFeed.tsx +1 -7
- package/src/ui/feed/__tests__/thread-preview.test.ts +123 -10
- package/src/ui/feed/__tests__/timeline-cards.test.ts +18 -1
- package/src/ui/layouts/BaseLayout.tsx +5 -0
- package/src/ui/pages/ArchivePage.tsx +1 -1
- package/src/ui/pages/BrandPage.tsx +1 -1
- package/src/ui/pages/CollectionPage.tsx +0 -1
- package/src/ui/pages/CollectionsPage.tsx +2 -2
- package/src/ui/pages/ComposePage.tsx +1 -1
- package/src/ui/pages/FeaturedPage.tsx +1 -1
- package/src/ui/pages/HomePage.tsx +1 -1
- package/src/ui/pages/PostPage.tsx +1 -1
- package/src/ui/pages/SearchPage.tsx +1 -1
- package/src/ui/pages/SmartCollectionPage.tsx +2 -3
- package/src/ui/pages/SubscribePage.tsx +1 -1
- package/src/ui/pages/ThemeSamplePage.tsx +1 -1
- package/src/ui/shared/MediaGallery.tsx +1 -1
- package/src/vendor/datastar.js +9 -1956
- package/src/vendor/datastar.js.map +4 -4
- package/dist/client/_assets/chunks/sortable-list-BJyd-LXE.js +0 -2
- package/dist/client/_assets/chunks/unsafe-svg-DU_DNMy5.js +0 -2
- package/dist/client/_assets/client-D4AT9Iqr.js +0 -295
- package/dist/client/_assets/client-DRuw7XCt.css +0 -2
- package/dist/client/_assets/client-author-DQ8R-8KR.css +0 -2
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
3
|
import { createI18n } from "../../../i18n/index.js";
|
|
4
4
|
import { attachSession } from "../../../middleware/session.js";
|
|
5
5
|
import { requireAuth } from "../../../middleware/auth.js";
|
|
6
|
-
import { signinRoutes } from "../signin.js";
|
|
6
|
+
import { limitApiSignin, signinRoutes } from "../signin.js";
|
|
7
|
+
import { createApp } from "../../../app.js";
|
|
8
|
+
import { createTestDatabase } from "../../../__tests__/helpers/db.js";
|
|
9
|
+
import { createMemoryRateLimiter } from "../../../lib/rate-limit-memory.js";
|
|
7
10
|
import type { Bindings } from "../../../types.js";
|
|
8
11
|
import type { AppVariables } from "../../../types/app-context.js";
|
|
9
12
|
|
|
@@ -133,3 +136,165 @@ describe("stale session redirect loop", () => {
|
|
|
133
136
|
expect(await signin.text()).toContain(SIGNIN_FORM_MARKER);
|
|
134
137
|
});
|
|
135
138
|
});
|
|
139
|
+
|
|
140
|
+
describe("POST /signin rate limit", () => {
|
|
141
|
+
// better-auth's own sign-in takes the same password, so its limiter has to
|
|
142
|
+
// run before the better-auth handler, which answers without yielding.
|
|
143
|
+
it("limits better-auth's sign-in ahead of the better-auth handler", () => {
|
|
144
|
+
const routes = createApp().routes;
|
|
145
|
+
const limiter = routes.findIndex(
|
|
146
|
+
(route) =>
|
|
147
|
+
route.method === "POST" && route.path === "/api/auth/sign-in/email",
|
|
148
|
+
);
|
|
149
|
+
// The last match: `noStore()` is mounted on the same path first.
|
|
150
|
+
const handler = routes.findLastIndex(
|
|
151
|
+
(route) => route.method === "ALL" && route.path === "/api/auth/*",
|
|
152
|
+
);
|
|
153
|
+
expect(limiter).toBeGreaterThanOrEqual(0);
|
|
154
|
+
expect(limiter).toBeLessThan(handler);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
function createGuessingApp({ demoMode = false } = {}) {
|
|
158
|
+
const signInEmail = vi.fn(async () => {
|
|
159
|
+
throw new Error("Invalid email or password");
|
|
160
|
+
});
|
|
161
|
+
const rateLimiter = createMemoryRateLimiter();
|
|
162
|
+
const app = new Hono<Env>();
|
|
163
|
+
app.use("*", async (c, next) => {
|
|
164
|
+
c.env = {} as Bindings;
|
|
165
|
+
c.set("auth", {
|
|
166
|
+
api: { signInEmail },
|
|
167
|
+
} as unknown as AppVariables["auth"]);
|
|
168
|
+
c.set("rateLimiter", rateLimiter);
|
|
169
|
+
c.set("appConfig", {
|
|
170
|
+
siteName: "Jant",
|
|
171
|
+
sitePathPrefix: "",
|
|
172
|
+
rateLimit: { enabled: true, searchPerMinute: 30 },
|
|
173
|
+
demoMode,
|
|
174
|
+
} as AppVariables["appConfig"]);
|
|
175
|
+
c.set("lang", "en");
|
|
176
|
+
c.set("i18n", createI18n("en"));
|
|
177
|
+
await next();
|
|
178
|
+
});
|
|
179
|
+
app.route("/", signinRoutes);
|
|
180
|
+
// Mounted as `app.tsx` mounts it, with a stand-in for better-auth that
|
|
181
|
+
// reads the body it was sent.
|
|
182
|
+
const betterAuthSignIn = vi.fn(async (request: Request) =>
|
|
183
|
+
Response.json({
|
|
184
|
+
email: ((await request.json()) as { email: string }).email,
|
|
185
|
+
}),
|
|
186
|
+
);
|
|
187
|
+
app.post("/api/auth/sign-in/email", limitApiSignin);
|
|
188
|
+
app.all("/api/auth/*", (c) => betterAuthSignIn(c.req.raw));
|
|
189
|
+
return { app, signInEmail, betterAuthSignIn };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function attempt(app: Hono<Env>, email: string, ip: string) {
|
|
193
|
+
return app.request("/signin", {
|
|
194
|
+
method: "POST",
|
|
195
|
+
headers: {
|
|
196
|
+
"Content-Type": "application/json",
|
|
197
|
+
"CF-Connecting-IP": ip,
|
|
198
|
+
},
|
|
199
|
+
body: JSON.stringify({ email, password: "guess-password" }),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
it("stops password guesses at one account from many clients", async () => {
|
|
204
|
+
const { app, signInEmail } = createGuessingApp();
|
|
205
|
+
|
|
206
|
+
for (let i = 0; i < 10; i++) {
|
|
207
|
+
await attempt(app, "owner@example.com", `203.0.113.${i}`);
|
|
208
|
+
}
|
|
209
|
+
const res = await attempt(app, "Owner@Example.com", "203.0.113.99");
|
|
210
|
+
|
|
211
|
+
await expect(res.text()).resolves.toContain("Too many sign-in attempts");
|
|
212
|
+
expect(signInEmail).toHaveBeenCalledTimes(10);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("stops one client guessing across many accounts", async () => {
|
|
216
|
+
const { app, signInEmail } = createGuessingApp();
|
|
217
|
+
|
|
218
|
+
for (let i = 0; i < 20; i++) {
|
|
219
|
+
await attempt(app, `user${i}@example.com`, "203.0.113.1");
|
|
220
|
+
}
|
|
221
|
+
const res = await attempt(app, "another@example.com", "203.0.113.1");
|
|
222
|
+
|
|
223
|
+
await expect(res.text()).resolves.toContain("Too many sign-in attempts");
|
|
224
|
+
expect(signInEmail).toHaveBeenCalledTimes(20);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("counts better-auth's sign-in against the same limits", async () => {
|
|
228
|
+
const { app, betterAuthSignIn } = createGuessingApp();
|
|
229
|
+
const apiAttempt = (ip: string) =>
|
|
230
|
+
app.request("/api/auth/sign-in/email", {
|
|
231
|
+
method: "POST",
|
|
232
|
+
headers: { "Content-Type": "application/json", "CF-Connecting-IP": ip },
|
|
233
|
+
body: JSON.stringify({ email: "owner@example.com", password: "guess" }),
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const passed = await apiAttempt("203.0.113.1");
|
|
237
|
+
await expect(passed.json()).resolves.toEqual({
|
|
238
|
+
email: "owner@example.com",
|
|
239
|
+
});
|
|
240
|
+
for (let i = 0; i < 9; i++) {
|
|
241
|
+
await attempt(app, "owner@example.com", `203.0.113.${i + 10}`);
|
|
242
|
+
}
|
|
243
|
+
const limited = await apiAttempt("203.0.113.99");
|
|
244
|
+
|
|
245
|
+
expect(limited.status).toBe(429);
|
|
246
|
+
expect(limited.headers.get("X-Retry-After")).toMatch(/^[1-9]\d*$/);
|
|
247
|
+
expect(betterAuthSignIn).toHaveBeenCalledTimes(1);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// Every demo visitor signs in to the one published account.
|
|
251
|
+
it("lets many clients sign in to the demo account", async () => {
|
|
252
|
+
const { app, signInEmail } = createGuessingApp({ demoMode: true });
|
|
253
|
+
|
|
254
|
+
for (let i = 0; i < 30; i++) {
|
|
255
|
+
await attempt(app, "demo@jant.me", `203.0.113.${i}`);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
expect(signInEmail).toHaveBeenCalledTimes(30);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
describe("POST /api/auth/sign-in/email in the full app", () => {
|
|
263
|
+
it("answers 429 once one client passes the sign-in limit", async () => {
|
|
264
|
+
const { sqlite } = createTestDatabase();
|
|
265
|
+
const app = createApp();
|
|
266
|
+
const env = {
|
|
267
|
+
SITE_ORIGIN: "https://blog.example",
|
|
268
|
+
AUTH_SECRET: "x".repeat(40),
|
|
269
|
+
NODE_SQLITE: sqlite,
|
|
270
|
+
} as unknown as Bindings;
|
|
271
|
+
const executionCtx = {
|
|
272
|
+
waitUntil() {},
|
|
273
|
+
passThroughOnException() {},
|
|
274
|
+
props: {},
|
|
275
|
+
} as unknown as Parameters<typeof app.fetch>[2];
|
|
276
|
+
const signIn = (n: number) =>
|
|
277
|
+
app.fetch(
|
|
278
|
+
new Request("https://blog.example/api/auth/sign-in/email", {
|
|
279
|
+
method: "POST",
|
|
280
|
+
headers: { "Content-Type": "application/json" },
|
|
281
|
+
body: JSON.stringify({
|
|
282
|
+
email: `guess${n}@example.com`,
|
|
283
|
+
password: "guess-password",
|
|
284
|
+
}),
|
|
285
|
+
}),
|
|
286
|
+
env,
|
|
287
|
+
executionCtx,
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
for (let n = 0; n < 20; n++) {
|
|
291
|
+
expect((await signIn(n)).status, `attempt ${n + 1}`).not.toBe(429);
|
|
292
|
+
}
|
|
293
|
+
const limited = await signIn(20);
|
|
294
|
+
|
|
295
|
+
expect(limited.status).toBe(429);
|
|
296
|
+
await expect(limited.json()).resolves.toMatchObject({
|
|
297
|
+
message: expect.stringContaining("Too many sign-in attempts"),
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
});
|
package/src/routes/auth/dev.ts
CHANGED
|
@@ -2,19 +2,16 @@ import { Hono } from "hono";
|
|
|
2
2
|
import type { Bindings } from "../../types.js";
|
|
3
3
|
import type { AppVariables } from "../../types/app-context.js";
|
|
4
4
|
import { getDevApiToken } from "../../lib/env.js";
|
|
5
|
+
import { getClientIp } from "../../lib/rate-limit.js";
|
|
5
6
|
import { hasValidLocalDevToken } from "../../middleware/auth.js";
|
|
6
|
-
import { toPublicPath } from "../../lib/url.js";
|
|
7
|
+
import { isSafeInternalRedirect, toPublicPath } from "../../lib/url.js";
|
|
7
8
|
|
|
8
9
|
type Env = { Bindings: Bindings; Variables: AppVariables };
|
|
9
10
|
|
|
10
11
|
const DEFAULT_REDIRECT_PATH = "/settings";
|
|
11
12
|
|
|
12
13
|
function normalizeRedirectPath(path?: string): string {
|
|
13
|
-
|
|
14
|
-
return DEFAULT_REDIRECT_PATH;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return path;
|
|
14
|
+
return isSafeInternalRedirect(path) ? path : DEFAULT_REDIRECT_PATH;
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
export const devAuthRoutes = new Hono<Env>();
|
|
@@ -26,6 +23,7 @@ devAuthRoutes.get("/__dev/login", async (c) => {
|
|
|
26
23
|
!hasValidLocalDevToken(
|
|
27
24
|
c.req.url,
|
|
28
25
|
c.req.header("host"),
|
|
26
|
+
getClientIp(c),
|
|
29
27
|
token,
|
|
30
28
|
getDevApiToken(c.env),
|
|
31
29
|
)
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
getHostedControlPlaneSsoSecret,
|
|
9
9
|
} from "../../lib/env.js";
|
|
10
10
|
import { DomainError, NotFoundError } from "../../lib/errors.js";
|
|
11
|
-
import {
|
|
11
|
+
import { getClientIp } from "../../lib/rate-limit.js";
|
|
12
|
+
import { isSafeInternalRedirect, toPublicPath } from "../../lib/url.js";
|
|
12
13
|
import { renderHostedSsoExpiredPage } from "./hosted-sso-expired-page.js";
|
|
13
14
|
|
|
14
15
|
type Env = { Bindings: Bindings; Variables: AppVariables };
|
|
@@ -17,11 +18,7 @@ const DEFAULT_REDIRECT_PATH = "/settings";
|
|
|
17
18
|
const EXPIRED_SIGNIN_LINK_MESSAGE = "This sign-in link has expired.";
|
|
18
19
|
|
|
19
20
|
function normalizeRedirectPath(path?: string): string {
|
|
20
|
-
|
|
21
|
-
return DEFAULT_REDIRECT_PATH;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return path;
|
|
21
|
+
return isSafeInternalRedirect(path) ? path : DEFAULT_REDIRECT_PATH;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
function getHostedControlPlaneReturnTarget(env: object | undefined | null): {
|
|
@@ -58,9 +55,15 @@ hostedSsoRoutes.get("/__sso", async (c) => {
|
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
try {
|
|
58
|
+
const clientIp = getClientIp(c);
|
|
61
59
|
const result = await c.var.hostedHandoff.completeFromSignedToken({
|
|
62
60
|
currentSiteId: c.var.currentSite.id,
|
|
63
61
|
token,
|
|
62
|
+
client: {
|
|
63
|
+
userAgent: c.req.header("User-Agent") ?? "",
|
|
64
|
+
ipAddress: clientIp === "unknown" ? "" : clientIp,
|
|
65
|
+
sessionToken: c.var.session?.session.token ?? null,
|
|
66
|
+
},
|
|
64
67
|
});
|
|
65
68
|
|
|
66
69
|
const authContext = await c.var.auth.$context;
|
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
} from "../../lib/schemas.js";
|
|
57
57
|
import { buildPageTitle } from "../../lib/page-title.js";
|
|
58
58
|
import { mapIanaToTimezone } from "../../lib/timezones.js";
|
|
59
|
+
import { readConfigEnvValue } from "../../lib/env-values.js";
|
|
59
60
|
import { getI18n } from "../../i18n/index.js";
|
|
60
61
|
import { isCurrentSiteMember } from "../../middleware/auth.js";
|
|
61
62
|
import type { I18n } from "../../i18n/i18n.js";
|
|
@@ -64,6 +65,7 @@ import {
|
|
|
64
65
|
resolveSupportedLocaleTag,
|
|
65
66
|
} from "../../i18n/supported-locales.js";
|
|
66
67
|
import { toPublicPath } from "../../lib/url.js";
|
|
68
|
+
import { checkRequestRateLimit } from "../../lib/rate-limit.js";
|
|
67
69
|
import { ONBOARDING_STATUS } from "../../lib/constants.js";
|
|
68
70
|
import { announceInBackground } from "../discover-announce.js";
|
|
69
71
|
import {
|
|
@@ -83,6 +85,9 @@ import {
|
|
|
83
85
|
type DiscoverCopy,
|
|
84
86
|
} from "../../ui/dash/settings/discover-copy.js";
|
|
85
87
|
|
|
88
|
+
/** Setup submissions allowed per client in a window. */
|
|
89
|
+
const SETUP_ATTEMPTS_PER_CLIENT = 20;
|
|
90
|
+
const SETUP_WINDOW_SEC = 10 * 60;
|
|
86
91
|
type Env = { Bindings: Bindings; Variables: AppVariables };
|
|
87
92
|
|
|
88
93
|
/**
|
|
@@ -777,10 +782,11 @@ setupRoutes.get("/setup", async (c) => {
|
|
|
777
782
|
contentLanguage={
|
|
778
783
|
// On a named site the control plane's guess is already stored, so
|
|
779
784
|
// offering it back is offering the site's current language. On an
|
|
780
|
-
// unnamed one nothing has been stored yet
|
|
781
|
-
//
|
|
785
|
+
// unnamed one nothing has been stored yet: the operator's
|
|
786
|
+
// SITE_LANGUAGE comes first, then the browser's header.
|
|
782
787
|
askSiteName
|
|
783
|
-
?
|
|
788
|
+
? (readConfigEnvValue(c.env, "SITE_LANGUAGE") ??
|
|
789
|
+
resolveSupportedLocaleTag(c.req.header("Accept-Language")))
|
|
784
790
|
: appConfig.siteLanguage
|
|
785
791
|
}
|
|
786
792
|
// Only a named site has a name worth showing: until the second screen
|
|
@@ -979,8 +985,13 @@ async function storeSiteAnswers(
|
|
|
979
985
|
browserLanguage: body.language,
|
|
980
986
|
// Left alone on a site whose clock the control plane already set: this
|
|
981
987
|
// screen can be opened from anywhere, and the browser reporting a
|
|
982
|
-
// different zone is not the author moving their site.
|
|
983
|
-
|
|
988
|
+
// different zone is not the author moving their site. Left alone too
|
|
989
|
+
// when the operator set TIME_ZONE: storing the browser's zone would
|
|
990
|
+
// outrank it for good.
|
|
991
|
+
timeZone:
|
|
992
|
+
siteName && !readConfigEnvValue(c.env, "TIME_ZONE")
|
|
993
|
+
? mapIanaToTimezone(body.timezone ?? "")
|
|
994
|
+
: undefined,
|
|
984
995
|
},
|
|
985
996
|
{ oldLanguage: c.var.appConfig.siteLanguage },
|
|
986
997
|
{
|
|
@@ -1008,6 +1019,25 @@ setupRoutes.post("/setup", async (c) => {
|
|
|
1008
1019
|
if (status === ONBOARDING_STATUS.COMPLETED)
|
|
1009
1020
|
return c.redirect(toPublicPath("/", c.var.appConfig.sitePathPrefix));
|
|
1010
1021
|
|
|
1022
|
+
const limit = await checkRequestRateLimit(c, {
|
|
1023
|
+
name: "setup",
|
|
1024
|
+
limit: SETUP_ATTEMPTS_PER_CLIENT,
|
|
1025
|
+
windowSec: SETUP_WINDOW_SEC,
|
|
1026
|
+
});
|
|
1027
|
+
if (!limit.ok) {
|
|
1028
|
+
const i18n = getI18n(c);
|
|
1029
|
+
return dsToast(
|
|
1030
|
+
i18n._(
|
|
1031
|
+
msg({
|
|
1032
|
+
message: "Too many setup attempts. Wait a few minutes and try again.",
|
|
1033
|
+
comment:
|
|
1034
|
+
"@context: Error toast when setup attempts hit the rate limit",
|
|
1035
|
+
}),
|
|
1036
|
+
),
|
|
1037
|
+
"error",
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1011
1041
|
const body = await c.req.json<Record<string, string>>();
|
|
1012
1042
|
|
|
1013
1043
|
return status === ONBOARDING_STATUS.PENDING
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Sign-in / Sign-out Routes
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { Hono } from "hono";
|
|
5
|
+
import { Hono, type Context, type MiddlewareHandler } from "hono";
|
|
6
6
|
import type { FC } from "hono/jsx";
|
|
7
7
|
import { msg } from "@lingui/core/macro";
|
|
8
8
|
import { useLingui } from "../../i18n/context.js";
|
|
@@ -16,9 +16,90 @@ import { getI18n } from "../../i18n/index.js";
|
|
|
16
16
|
import { getHostedControlPlaneSigninUrl } from "../../lib/hosted-signin.js";
|
|
17
17
|
import { isCurrentSiteMember } from "../../middleware/auth.js";
|
|
18
18
|
import { isSafeInternalRedirect, toPublicPath } from "../../lib/url.js";
|
|
19
|
+
import { checkRequestRateLimit } from "../../lib/rate-limit.js";
|
|
20
|
+
|
|
21
|
+
/** Sign-in attempts allowed per window, from one client and for one account. */
|
|
22
|
+
const SIGNIN_ATTEMPTS_PER_CLIENT = 20;
|
|
23
|
+
const SIGNIN_ATTEMPTS_PER_ACCOUNT = 10;
|
|
24
|
+
const SIGNIN_WINDOW_SEC = 10 * 60;
|
|
19
25
|
|
|
20
26
|
type Env = { Bindings: Bindings; Variables: AppVariables };
|
|
21
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Check one more sign-in attempt against the limits, and count it.
|
|
30
|
+
*
|
|
31
|
+
* Two buckets against password guessing: one per client, and one per
|
|
32
|
+
* account, so neither many addresses from one client nor one address from
|
|
33
|
+
* many clients gets unlimited tries. The demo's visitors all sign in to one
|
|
34
|
+
* published account, so there the account bucket would lock everyone out
|
|
35
|
+
* after a handful of visits; the per-client one still applies.
|
|
36
|
+
*
|
|
37
|
+
* @param c - The request, with its app config and rate limiter
|
|
38
|
+
* @param email - The address being signed in to; `""` when unknown
|
|
39
|
+
* @returns `retryAfterSec` when the attempt is over a limit, `null` otherwise
|
|
40
|
+
* @example
|
|
41
|
+
* const limited = await checkSigninLimits(c, "owner@example.com");
|
|
42
|
+
*/
|
|
43
|
+
export async function checkSigninLimits(
|
|
44
|
+
c: Context<Env>,
|
|
45
|
+
email: string,
|
|
46
|
+
): Promise<{ retryAfterSec: number } | null> {
|
|
47
|
+
const account = email.trim().toLowerCase();
|
|
48
|
+
const limits = await Promise.all([
|
|
49
|
+
checkRequestRateLimit(c, {
|
|
50
|
+
name: "signin",
|
|
51
|
+
limit: SIGNIN_ATTEMPTS_PER_CLIENT,
|
|
52
|
+
windowSec: SIGNIN_WINDOW_SEC,
|
|
53
|
+
}),
|
|
54
|
+
...(c.var.appConfig.demoMode || !account
|
|
55
|
+
? []
|
|
56
|
+
: [
|
|
57
|
+
checkRequestRateLimit(c, {
|
|
58
|
+
name: "signin-account",
|
|
59
|
+
key: account,
|
|
60
|
+
limit: SIGNIN_ATTEMPTS_PER_ACCOUNT,
|
|
61
|
+
windowSec: SIGNIN_WINDOW_SEC,
|
|
62
|
+
}),
|
|
63
|
+
]),
|
|
64
|
+
]);
|
|
65
|
+
const blocked = limits.flatMap((limit) =>
|
|
66
|
+
limit.ok ? [] : [limit.retryAfterSec],
|
|
67
|
+
);
|
|
68
|
+
return blocked.length > 0 ? { retryAfterSec: Math.max(1, ...blocked) } : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* better-auth's own sign-in endpoint, `POST /api/auth/sign-in/email`, takes
|
|
73
|
+
* the same password as `/signin`, so it counts against the same limits. It
|
|
74
|
+
* runs ahead of the better-auth handler and answers a limited attempt the way
|
|
75
|
+
* better-auth's own limiter does.
|
|
76
|
+
*/
|
|
77
|
+
export const limitApiSignin: MiddlewareHandler<Env> = async (c, next) => {
|
|
78
|
+
// A clone, so better-auth still reads the body it was sent.
|
|
79
|
+
const body: unknown = await c.req.raw
|
|
80
|
+
.clone()
|
|
81
|
+
.json()
|
|
82
|
+
.catch(() => null);
|
|
83
|
+
const email =
|
|
84
|
+
body &&
|
|
85
|
+
typeof body === "object" &&
|
|
86
|
+
"email" in body &&
|
|
87
|
+
typeof body.email === "string"
|
|
88
|
+
? body.email
|
|
89
|
+
: "";
|
|
90
|
+
const limited = await checkSigninLimits(c, email);
|
|
91
|
+
if (limited) {
|
|
92
|
+
return c.json(
|
|
93
|
+
{
|
|
94
|
+
message: "Too many sign-in attempts. Wait a few minutes and try again.",
|
|
95
|
+
},
|
|
96
|
+
429,
|
|
97
|
+
{ "X-Retry-After": String(limited.retryAfterSec) },
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
await next();
|
|
101
|
+
};
|
|
102
|
+
|
|
22
103
|
const SigninContent: FC<{
|
|
23
104
|
demoEmail?: string;
|
|
24
105
|
demoPassword?: string;
|
|
@@ -212,6 +293,20 @@ signinRoutes.post("/signin", async (c) => {
|
|
|
212
293
|
}
|
|
213
294
|
|
|
214
295
|
const { email, password } = parsed.data;
|
|
296
|
+
|
|
297
|
+
if (await checkSigninLimits(c, email)) {
|
|
298
|
+
return dsToast(
|
|
299
|
+
i18n._(
|
|
300
|
+
msg({
|
|
301
|
+
message:
|
|
302
|
+
"Too many sign-in attempts. Wait a few minutes and try again.",
|
|
303
|
+
comment:
|
|
304
|
+
"@context: Error toast when sign-in attempts hit the rate limit",
|
|
305
|
+
}),
|
|
306
|
+
),
|
|
307
|
+
"error",
|
|
308
|
+
);
|
|
309
|
+
}
|
|
215
310
|
const rawRedirect =
|
|
216
311
|
body && typeof body === "object" && "redirect" in body
|
|
217
312
|
? (body as { redirect?: unknown }).redirect
|
package/src/routes/compose.tsx
CHANGED
|
@@ -202,53 +202,53 @@ composeRoutes.post("/thread", async (c) => {
|
|
|
202
202
|
const status = firstSchema.status ?? "published";
|
|
203
203
|
const isDraft = status === "draft";
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
data.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
205
|
+
const threadItems = postSchemas.map((data, index) => ({
|
|
206
|
+
data: {
|
|
207
|
+
format: data.format,
|
|
208
|
+
// Every post may carry its own permalink; blank means the service
|
|
209
|
+
// generates one (title-derived for the root, random id for replies).
|
|
210
|
+
slug: data.slug || undefined,
|
|
211
|
+
title:
|
|
212
|
+
data.format === "quote"
|
|
213
|
+
? data.sourceName || undefined
|
|
214
|
+
: data.title || undefined,
|
|
215
|
+
body: data.body || undefined,
|
|
216
|
+
bodyMarkdown: data.bodyMarkdown || undefined,
|
|
217
|
+
status,
|
|
218
|
+
visibility: index === 0 ? data.visibility || undefined : undefined,
|
|
219
|
+
url:
|
|
220
|
+
data.format === "quote"
|
|
221
|
+
? data.sourceUrl || undefined
|
|
222
|
+
: data.url || undefined,
|
|
223
|
+
quoteText: data.quoteText || undefined,
|
|
224
|
+
rating: data.rating || undefined,
|
|
225
|
+
collectionIds: index === 0 ? data.collectionIds : undefined,
|
|
226
|
+
replyToId: index === 0 ? data.replyToId : undefined,
|
|
227
|
+
quietReply: data.quietReply,
|
|
228
|
+
// Thread-level, so only the root states them; replies inherit.
|
|
229
|
+
language: index === 0 ? data.language : undefined,
|
|
230
|
+
translationOfId: index === 0 ? data.translationOfId : undefined,
|
|
231
|
+
// Replies may carry their own date; when they don't, the service
|
|
232
|
+
// inherits the root's rather than stamping "now".
|
|
233
|
+
publishedAt: data.publishedAt,
|
|
234
|
+
createdAt: data.createdAt,
|
|
235
|
+
updatedAt: data.updatedAt,
|
|
236
|
+
},
|
|
237
|
+
attachments: data.attachments,
|
|
238
|
+
}));
|
|
239
|
+
// Re-editing a saved thread draft replaces it with the new version.
|
|
240
|
+
const threadPosts = replaceThreadId
|
|
241
|
+
? await c.var.services.posts.replaceThreadDraft(
|
|
242
|
+
replaceThreadId,
|
|
243
|
+
threadItems,
|
|
244
|
+
storageOpts,
|
|
245
|
+
summaryConfig,
|
|
246
|
+
)
|
|
247
|
+
: await c.var.services.posts.createThreadWithAttachments(
|
|
248
|
+
threadItems,
|
|
249
|
+
storageOpts,
|
|
250
|
+
summaryConfig,
|
|
251
|
+
);
|
|
252
252
|
|
|
253
253
|
const root = threadPosts[0];
|
|
254
254
|
if (!root) {
|
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
createTestDatabase,
|
|
11
11
|
DEFAULT_TEST_SITE_ID,
|
|
12
12
|
} from "../../../__tests__/helpers/db.js";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
createSettingsService,
|
|
15
|
+
type AvatarUploadData,
|
|
16
|
+
} from "../../../services/settings.js";
|
|
14
17
|
import { createMediaService } from "../../../services/media.js";
|
|
15
18
|
import {
|
|
16
19
|
arrayBufferToBase64,
|
|
@@ -27,16 +30,22 @@ function createMockStorage(): StorageDriver {
|
|
|
27
30
|
};
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
const PNG_SIGNATURE = new Uint8Array([
|
|
34
|
+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
|
|
35
|
+
]);
|
|
36
|
+
|
|
30
37
|
function createMockFile(
|
|
31
38
|
name: string,
|
|
32
39
|
type: string,
|
|
33
40
|
size: number,
|
|
34
|
-
|
|
41
|
+
head: Uint8Array = PNG_SIGNATURE,
|
|
42
|
+
): AvatarUploadData["file"] {
|
|
35
43
|
return {
|
|
36
44
|
name,
|
|
37
45
|
type,
|
|
38
46
|
size,
|
|
39
47
|
stream: () => new ReadableStream(),
|
|
48
|
+
slice: () => new Blob([head]),
|
|
40
49
|
};
|
|
41
50
|
}
|
|
42
51
|
|
|
@@ -89,7 +98,7 @@ describe("Settings - Avatar Upload Logic", () => {
|
|
|
89
98
|
},
|
|
90
99
|
);
|
|
91
100
|
|
|
92
|
-
const mediaList = await mediaService.
|
|
101
|
+
const mediaList = (await mediaService.listPage({ limit: 10 })).media;
|
|
93
102
|
expect(mediaList).toHaveLength(1);
|
|
94
103
|
expect(mediaList[0].originalName).toBe("logo.png");
|
|
95
104
|
expect(mediaList[0].mimeType).toBe("image/png");
|
|
@@ -120,7 +129,7 @@ describe("Settings - Avatar Upload Logic", () => {
|
|
|
120
129
|
it("stores apple-touch-icon in storage and sets key in settings", async () => {
|
|
121
130
|
const storage = createMockStorage();
|
|
122
131
|
const file = createMockFile("logo.png", "image/png", 5000);
|
|
123
|
-
const appleTouchData =
|
|
132
|
+
const appleTouchData = PNG_SIGNATURE.slice().buffer;
|
|
124
133
|
|
|
125
134
|
await settingsService.uploadAvatar(
|
|
126
135
|
{ file, appleTouchIcon: appleTouchData },
|
|
@@ -176,6 +185,52 @@ describe("Settings - Avatar Upload Logic", () => {
|
|
|
176
185
|
).rejects.toThrow("File type not allowed");
|
|
177
186
|
});
|
|
178
187
|
|
|
188
|
+
it("refuses an SVG, which can carry script", async () => {
|
|
189
|
+
const storage = createMockStorage();
|
|
190
|
+
const file = createMockFile(
|
|
191
|
+
"logo.svg",
|
|
192
|
+
"image/svg+xml",
|
|
193
|
+
500,
|
|
194
|
+
new TextEncoder().encode("<svg onload=alert(1)>"),
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
await expect(
|
|
198
|
+
settingsService.uploadAvatar(
|
|
199
|
+
{ file },
|
|
200
|
+
{
|
|
201
|
+
media: mediaService,
|
|
202
|
+
storage,
|
|
203
|
+
storageProvider: "r2",
|
|
204
|
+
maxFileSizeMB: 500,
|
|
205
|
+
},
|
|
206
|
+
),
|
|
207
|
+
).rejects.toThrow("Upload a PNG, JPEG, or WebP image.");
|
|
208
|
+
expect(storage.put).not.toHaveBeenCalled();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("refuses a file whose bytes aren't the image type it claims", async () => {
|
|
212
|
+
const storage = createMockStorage();
|
|
213
|
+
const file = createMockFile(
|
|
214
|
+
"logo.png",
|
|
215
|
+
"image/png",
|
|
216
|
+
500,
|
|
217
|
+
new TextEncoder().encode("<html>"),
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
await expect(
|
|
221
|
+
settingsService.uploadAvatar(
|
|
222
|
+
{ file },
|
|
223
|
+
{
|
|
224
|
+
media: mediaService,
|
|
225
|
+
storage,
|
|
226
|
+
storageProvider: "r2",
|
|
227
|
+
maxFileSizeMB: 500,
|
|
228
|
+
},
|
|
229
|
+
),
|
|
230
|
+
).rejects.toThrow("PNG");
|
|
231
|
+
expect(storage.put).not.toHaveBeenCalled();
|
|
232
|
+
});
|
|
233
|
+
|
|
179
234
|
it("throws ValidationError for oversized file", async () => {
|
|
180
235
|
const storage = createMockStorage();
|
|
181
236
|
const file = createMockFile("big.png", "image/png", 501 * 1024 * 1024);
|