stkit 17.3.1__tar.gz → 17.4.0__tar.gz
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.
- {stkit-17.3.1 → stkit-17.4.0}/CHANGELOG.md +22 -0
- {stkit-17.3.1 → stkit-17.4.0}/PKG-INFO +3 -3
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/uv.lock +9 -9
- {stkit-17.3.1 → stkit-17.4.0}/pyproject.toml +4 -3
- {stkit-17.3.1 → stkit-17.4.0}/stk/__init__.py +3 -1
- {stkit-17.3.1 → stkit-17.4.0}/stk/app.py +11 -1
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/develop.py +32 -0
- stkit-17.4.0/stk/migrations/versions/stk_0008_stk_message.py +37 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/notification/__init__.py +16 -9
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/CLAUDE.md +1 -1
- {stkit-17.3.1 → stkit-17.4.0}/stk/user/models.py +16 -6
- {stkit-17.3.1 → stkit-17.4.0}/stk/websocket.py +97 -7
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_cli.py +16 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_notifications.py +58 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_production_security.py +35 -2
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_smoke_pages.py +50 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_static_versioning.py +13 -0
- {stkit-17.3.1 → stkit-17.4.0}/.gitignore +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/LICENSE +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/README.md +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/SECURITY.md +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/.env-sample +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/.gitignore +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/README.md +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/minimal/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/minimal/app.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/minimal/migrations/364232ae77d5_add_note.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/minimal/note/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/minimal/note/models.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/minimal/note/templates/note/index.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/minimal/note/views.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/minimal/settings.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/minimal/templates/layout.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/pyproject.toml +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/tests/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/examples/minimal/tests/test_app.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/__main__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/agent_login.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/checks.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/agent.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/base.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/copy_rules.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/database.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/doctor.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/main.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/reports.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/smoke.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/users.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/cli/watch.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/extensions.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/files/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/files/models.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/files/store.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/files/views.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/mcp/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/mcp/models.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/mcp/server.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/mcp/views.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/env.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/script.py.mako +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/versions/stk_0001_initial_schema.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/versions/stk_0002_jobs.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/versions/stk_0003_files.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/versions/stk_0004_notifications.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/versions/stk_0005_mcp_tokens.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/versions/stk_0006_stk_mcp_token.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/migrations/versions/stk_0007_confirm_existing_users.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/notification/models.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/notification/views.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/portal/views.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/public/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/public/models.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/public/views.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/Dockerfile +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/README.md +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/__app__/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/__app__/app.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/__app__/settings.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/claude/skills/stk-api/SKILL.md +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/claude/skills/stk-blueprint/SKILL.md +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/claude/skills/stk-deploy/SKILL.md +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/claude/skills/stk-lessons/SKILL.md +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/claude/skills/stk-migrate/SKILL.md +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/docker-compose.yml +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/dockerignore +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/env-sample +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/github/workflows/checks.yml +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/gitignore +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/nginx/nginx.conf +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/nginx/stk.conf +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/postgres/init-db.sh +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/pyproject.toml +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/tests/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/app/tests/test_app.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/generator.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/scaffold/templates.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/security.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/settings.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/shell.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/VERSIONS.txt +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/css/app.css +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/css/layout.css +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/css/vuetify.min.css +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.animals.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.arrows-1.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.arrows-2.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.badges.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.brand-1.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.brand-2.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.buildings.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.charts.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.communication.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.computers.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.core.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.currencies.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.database.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.design-1.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.design-2.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.development.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.devices-1.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.devices-2.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.document.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.e-commerce.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.electrical.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.extensions.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.food.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.games.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.gender.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.gestures.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.health.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.laundry.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.letters.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.logic.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.map.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.math.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.media.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.mood.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.nature.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.numbers.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.photography.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.shapes.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.sport.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.symbols.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.system-1.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.system-2.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.system-3.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.text.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.vehicles.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.version-control.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.weather.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/fonts/tabler-icons.zodiac.woff2 +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/icons/tabler-icons.min.css +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/img/auth-bg.webp +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/img/favicon.ico +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/img/stk.svg +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/axios.min.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/components/NotificationDropdown.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/components/ThemeSwitcher.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/components/TransitionExpand.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/components/VerticalNavGroup.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/components/VerticalNavLink.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/components/VerticalNavSectionTitle.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/components/index.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/config.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/vue.min.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/js/vuetify.min.js +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/static/robots.txt +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/tasks/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/tasks/models.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/401.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/404.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/500.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/_brand.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/auth_layout.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/cms/activities.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/cms/jobs.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/cms/roles.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/cms/users.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/dashboard.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/index.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/layout.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/login-layout.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/mcp/tokens.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/_macros.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/_messages.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/change_password.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/confirm_email.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/change_notice.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/change_notice.txt +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/confirmation_instructions.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/confirmation_instructions.txt +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/login_instructions.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/login_instructions.txt +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/reset_instructions.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/reset_instructions.txt +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/reset_notice.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/reset_notice.txt +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/welcome.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/email/welcome.txt +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/forgot_password.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/login_user.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/mf_recovery.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/mf_recovery_codes.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/register_user.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/reset_password.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/send_confirmation.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/send_login.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/two_factor_select.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/two_factor_setup.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/two_factor_verify_code.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/wan_register.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/wan_signin.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/templates/security/wan_verify.html +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/user/__init__.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/user/forms.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/user/views.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/utils/email.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/utils/netguard.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/stk/utils/ratelimit.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_agent_operability.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_app_index.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_branding.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_builder_ux.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_composition.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_confirm_migration.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_copy_rules.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_csrf_exempt.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_error_handler.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_files.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_jobs.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_mcp.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_mcp_migration.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_migration_drift.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_netguard.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_revision_imports.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_route_collisions.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_scaffolder.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_security_compatibility.py +0 -0
- {stkit-17.3.1 → stkit-17.4.0}/tests/test_shell.py +0 -0
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v17.4.0 (2026-11-02)
|
|
4
|
+
|
|
5
|
+
Run `uv run stk db upgrade`: migration `stk_0008` adds the `stk_message` table.
|
|
6
|
+
|
|
7
|
+
- `broadcast` reaches a user's sockets from any process: another uvicorn worker, a durable job in `stk worker`, or `stk shell`. Messages go through `stk_message`, which each server process polls while it holds sockets, so delivery lags up to a quarter second. Every call is now a database write, so throttle rapid progress updates. `user_id` must be a numeric user id.
|
|
8
|
+
- `broadcast(..., session=)` and `notify(..., session=)` join the caller's transaction: sent at commit, dropped on rollback.
|
|
9
|
+
- `notify` from a durable job now reaches open pages instead of waiting for the next page load.
|
|
10
|
+
- `stk run` on a port that is already taken exits with the pid holding it, instead of uvicorn's easy-to-miss log line while the old server keeps serving.
|
|
11
|
+
- The dev extra requires Playwright 1.64. Older versions never reach network idle on a page that opens an EventSource, so `stk smoke` timed out there. Apps on an older lock: `uv lock --upgrade-package playwright`.
|
|
12
|
+
- `stk --version`, the MCP server info and `stk init` read the installed package version. 17.3.2 still reported 17.3.1, so apps made with it require `stkit>=17.3.1`.
|
|
13
|
+
|
|
14
|
+
## v17.3.2 (2026-11-01)
|
|
15
|
+
|
|
16
|
+
No migration required. Requires quart-security 2.2.0, which normalizes emails more fully: an account stored with a decomposed Unicode or punycode email must be rewritten with `quart_security.normalize_email` to sign in. ASCII addresses are unaffected.
|
|
17
|
+
|
|
18
|
+
- When an admin changes a user's email, the user is signed out everywhere and their MCP tokens are revoked, so reset and confirmation links sent to the old address stop working. Retyping the same address in other case is no change (Authentication).
|
|
19
|
+
- Pages behind `auth_required`, which includes every admin page, now come back after login. Before, the user always landed on the dashboard.
|
|
20
|
+
- One mailbox is one account: `josé@` composed and decomposed, or `münchen.de` and its punycode form, no longer make separate users. Passwords match whichever Unicode form they are typed in.
|
|
21
|
+
- Passkey sign-in refuses locked and unconfirmed accounts, like password login.
|
|
22
|
+
- `STK_PUBLIC_URL` with a trailing slash no longer closes every WebSocket with 4003.
|
|
23
|
+
- A static file is cached as immutable only under the version this instance would link to. During a rolling deploy an old instance could pin old bytes under a new URL for a year. An app test that requests a made-up `?v=` and expects `immutable` must build the URL with `url_for('static', ...)` instead.
|
|
24
|
+
|
|
3
25
|
## v17.3.1 (2026-10-31)
|
|
4
26
|
|
|
5
27
|
No migration required.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: stkit
|
|
3
|
-
Version: 17.
|
|
3
|
+
Version: 17.4.0
|
|
4
4
|
Summary: An async Quart framework optimized for AI-assisted development workflows
|
|
5
5
|
Project-URL: Documentation, https://docs.stkit.dev
|
|
6
6
|
Project-URL: Source, https://github.com/level09/stk
|
|
@@ -28,7 +28,7 @@ Requires-Dist: pillow>=13.0.0
|
|
|
28
28
|
Requires-Dist: psycopg2-binary>=2.9.10
|
|
29
29
|
Requires-Dist: python-dotenv>=1.2.2
|
|
30
30
|
Requires-Dist: qrcode>=8.2
|
|
31
|
-
Requires-Dist: quart-security<3,>=2.
|
|
31
|
+
Requires-Dist: quart-security<3,>=2.2.0
|
|
32
32
|
Requires-Dist: quart-session>=3.0.0
|
|
33
33
|
Requires-Dist: quart>=0.20.0
|
|
34
34
|
Requires-Dist: rich>=14.0.0
|
|
@@ -39,7 +39,7 @@ Requires-Dist: wtforms>=3.2.1
|
|
|
39
39
|
Provides-Extra: asgi
|
|
40
40
|
Requires-Dist: hypercorn>=0.17.0; extra == 'asgi'
|
|
41
41
|
Provides-Extra: dev
|
|
42
|
-
Requires-Dist: playwright; extra == 'dev'
|
|
42
|
+
Requires-Dist: playwright>=1.64; extra == 'dev'
|
|
43
43
|
Requires-Dist: pre-commit; extra == 'dev'
|
|
44
44
|
Requires-Dist: ptpython>=3.0.30; extra == 'dev'
|
|
45
45
|
Requires-Dist: ruff; extra == 'dev'
|
|
@@ -1414,11 +1414,11 @@ wheels = [
|
|
|
1414
1414
|
|
|
1415
1415
|
[[package]]
|
|
1416
1416
|
name = "pyasn1"
|
|
1417
|
-
version = "0.6.
|
|
1417
|
+
version = "0.6.5"
|
|
1418
1418
|
source = { registry = "https://pypi.org/simple" }
|
|
1419
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
1419
|
+
sdist = { url = "https://files.pythonhosted.org/packages/88/7e/3c0da41061a2021cac7cd524fd57092adbe5b515e8bf9005702e366802e2/pyasn1-0.6.5.tar.gz", hash = "sha256:6b11616a6bcf3a40e635f082bb232fa57b5e0dd7f517bd7ddd69ec3794508a47", size = 155152, upload-time = "2026-10-27T06:32:49.125Z" }
|
|
1420
1420
|
wheels = [
|
|
1421
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1421
|
+
{ url = "https://files.pythonhosted.org/packages/19/1f/3eefd5c84c35cae44549ce1c7f7e58f7945b34f5a6bce07a135438522073/pyasn1-0.6.5-py3-none-any.whl", hash = "sha256:4017b0fce125096b8573b39c989fdb1a4b19cf761e683398184550fea0e66587", size = 84807, upload-time = "2026-10-27T06:32:48.045Z" },
|
|
1422
1422
|
]
|
|
1423
1423
|
|
|
1424
1424
|
[[package]]
|
|
@@ -1654,7 +1654,7 @@ wheels = [
|
|
|
1654
1654
|
|
|
1655
1655
|
[[package]]
|
|
1656
1656
|
name = "quart-security"
|
|
1657
|
-
version = "2.0
|
|
1657
|
+
version = "2.2.0"
|
|
1658
1658
|
source = { registry = "https://pypi.org/simple" }
|
|
1659
1659
|
dependencies = [
|
|
1660
1660
|
{ name = "aiosmtplib" },
|
|
@@ -1673,9 +1673,9 @@ dependencies = [
|
|
|
1673
1673
|
{ name = "webauthn" },
|
|
1674
1674
|
{ name = "wtforms" },
|
|
1675
1675
|
]
|
|
1676
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
1676
|
+
sdist = { url = "https://files.pythonhosted.org/packages/5e/89/57c9ac93ded704454db3dd97c5932cee149bcded7aa4e002a8c2dd3e3b46/quart_security-2.2.0.tar.gz", hash = "sha256:b125b0fc1523b9fddc0929fb2d1bd63768c679bbdd4bbfffb03861f81a00d7d5", size = 45480, upload-time = "2026-11-01T12:04:07.306Z" }
|
|
1677
1677
|
wheels = [
|
|
1678
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1678
|
+
{ url = "https://files.pythonhosted.org/packages/5c/54/775f754344c5602b87a59b3c6eba8db9793a18b1a7c14e47c2355f8ac479/quart_security-2.2.0-py3-none-any.whl", hash = "sha256:d3b7cd1ecabb0b9610417a10d6a056eaaf12a7959a43509af565b41942f92542", size = 52995, upload-time = "2026-11-01T12:04:05.767Z" },
|
|
1679
1679
|
]
|
|
1680
1680
|
|
|
1681
1681
|
[[package]]
|
|
@@ -1976,7 +1976,7 @@ asyncio = [
|
|
|
1976
1976
|
|
|
1977
1977
|
[[package]]
|
|
1978
1978
|
name = "stkit"
|
|
1979
|
-
version = "17.
|
|
1979
|
+
version = "17.4.0"
|
|
1980
1980
|
source = { editable = "../../" }
|
|
1981
1981
|
dependencies = [
|
|
1982
1982
|
{ name = "aiosmtplib" },
|
|
@@ -2041,14 +2041,14 @@ requires-dist = [
|
|
|
2041
2041
|
{ name = "libpass", specifier = ">=1.9.0" },
|
|
2042
2042
|
{ name = "orjson", specifier = ">=3.11.6" },
|
|
2043
2043
|
{ name = "pillow", specifier = ">=13.0.0" },
|
|
2044
|
-
{ name = "playwright", marker = "extra == 'dev'" },
|
|
2044
|
+
{ name = "playwright", marker = "extra == 'dev'", specifier = ">=1.64" },
|
|
2045
2045
|
{ name = "pre-commit", marker = "extra == 'dev'" },
|
|
2046
2046
|
{ name = "psycopg2-binary", specifier = ">=2.9.10" },
|
|
2047
2047
|
{ name = "ptpython", marker = "extra == 'dev'", specifier = ">=3.0.30" },
|
|
2048
2048
|
{ name = "python-dotenv", specifier = ">=1.2.2" },
|
|
2049
2049
|
{ name = "qrcode", specifier = ">=8.2" },
|
|
2050
2050
|
{ name = "quart", specifier = ">=0.20.0" },
|
|
2051
|
-
{ name = "quart-security", specifier = ">=2.0
|
|
2051
|
+
{ name = "quart-security", specifier = ">=2.2.0,<3" },
|
|
2052
2052
|
{ name = "quart-session", specifier = ">=3.0.0" },
|
|
2053
2053
|
{ name = "redis", marker = "extra == 'full'", specifier = ">=7.1.0" },
|
|
2054
2054
|
{ name = "rich", specifier = ">=14.0.0" },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "stkit"
|
|
3
|
-
version = "17.
|
|
3
|
+
version = "17.4.0"
|
|
4
4
|
description = "An async Quart framework optimized for AI-assisted development workflows"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Level09", email = "hello@level09.com"}
|
|
@@ -30,7 +30,7 @@ dependencies = [
|
|
|
30
30
|
"python-dotenv>=1.2.2",
|
|
31
31
|
"qrcode>=8.2",
|
|
32
32
|
"quart>=0.20.0",
|
|
33
|
-
"quart-security>=2.
|
|
33
|
+
"quart-security>=2.2.0,<3",
|
|
34
34
|
"quart-session>=3.0.0",
|
|
35
35
|
"rich>=14.0.0",
|
|
36
36
|
"sqlalchemy[asyncio]>=2.0.41",
|
|
@@ -56,7 +56,8 @@ full = [
|
|
|
56
56
|
dev = [
|
|
57
57
|
"ruff",
|
|
58
58
|
"pre-commit",
|
|
59
|
-
|
|
59
|
+
# 1.64 stops counting an open EventSource against networkidle; older versions hang smoke.
|
|
60
|
+
"playwright>=1.64",
|
|
60
61
|
"ptpython>=3.0.30",
|
|
61
62
|
]
|
|
62
63
|
asgi = [
|
|
@@ -251,6 +251,10 @@ def register_static_versioning(app):
|
|
|
251
251
|
raise FileNotFoundError(f"no static file {values['filename']}")
|
|
252
252
|
values["v"] = _static_digest(path, path.stat().st_mtime_ns)
|
|
253
253
|
|
|
254
|
+
def _digest_of(filename):
|
|
255
|
+
path = app.static_file(filename)
|
|
256
|
+
return path and _static_digest(path, path.stat().st_mtime_ns)
|
|
257
|
+
|
|
254
258
|
@app.after_request
|
|
255
259
|
async def _cache_static(response):
|
|
256
260
|
if request.path.startswith(f"{app.static_url_path}/"):
|
|
@@ -258,7 +262,13 @@ def register_static_versioning(app):
|
|
|
258
262
|
# This response sets or clears a session cookie; a shared cache
|
|
259
263
|
# must never replay it to someone else.
|
|
260
264
|
policy = "private, no-store"
|
|
261
|
-
elif
|
|
265
|
+
elif (
|
|
266
|
+
response.status_code == 200
|
|
267
|
+
and request.endpoint == "static"
|
|
268
|
+
and request.args.get("v") == _digest_of(request.view_args["filename"])
|
|
269
|
+
):
|
|
270
|
+
# Only the version this instance would link to: during a rolling
|
|
271
|
+
# deploy an old instance must not pin old bytes under a new URL.
|
|
262
272
|
policy = "public, max-age=31536000, immutable"
|
|
263
273
|
else:
|
|
264
274
|
policy = "no-cache"
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"""Starting an app, serving it locally, and running its durable jobs."""
|
|
2
2
|
|
|
3
|
+
import errno
|
|
4
|
+
import socket
|
|
5
|
+
import subprocess
|
|
3
6
|
from pathlib import Path
|
|
4
7
|
|
|
5
8
|
import click
|
|
@@ -47,6 +50,8 @@ def init(name, source):
|
|
|
47
50
|
def run(host, port, reload):
|
|
48
51
|
"""Run a local development server (uvicorn, as in production)."""
|
|
49
52
|
import uvicorn
|
|
53
|
+
|
|
54
|
+
_require_free_port(host, port)
|
|
50
55
|
from quart.helpers import get_debug_flag
|
|
51
56
|
|
|
52
57
|
app = cli_app()
|
|
@@ -63,6 +68,33 @@ def run(host, port, reload):
|
|
|
63
68
|
)
|
|
64
69
|
|
|
65
70
|
|
|
71
|
+
def _require_free_port(host, port):
|
|
72
|
+
# uvicorn logs EADDRINUSE and exits, easy to miss when backgrounded while
|
|
73
|
+
# the old server keeps serving stale code.
|
|
74
|
+
with socket.socket() as probe:
|
|
75
|
+
# Bind as uvicorn does, so a TIME_WAIT leftover is not a false alarm.
|
|
76
|
+
probe.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
77
|
+
try:
|
|
78
|
+
probe.bind((host, port))
|
|
79
|
+
except OSError as exc:
|
|
80
|
+
if exc.errno != errno.EADDRINUSE:
|
|
81
|
+
raise
|
|
82
|
+
else:
|
|
83
|
+
return
|
|
84
|
+
try:
|
|
85
|
+
pids = subprocess.run(
|
|
86
|
+
["lsof", "-nP", f"-iTCP:{port}", "-sTCP:LISTEN", "-t"],
|
|
87
|
+
capture_output=True,
|
|
88
|
+
text=True,
|
|
89
|
+
).stdout.split()
|
|
90
|
+
except FileNotFoundError: # no lsof (slim containers): report without a pid
|
|
91
|
+
pids = []
|
|
92
|
+
holder = f" by pid {', '.join(pids)}" if pids else ""
|
|
93
|
+
raise click.ClickException(
|
|
94
|
+
f"port {port} is in use{holder}. Stop it or pass --port."
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
66
98
|
@click.command("worker")
|
|
67
99
|
@click.option(
|
|
68
100
|
"--timeout",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""stk messages: socket pushes routed through the database to every process."""
|
|
2
|
+
|
|
3
|
+
import sqlalchemy as sa
|
|
4
|
+
from alembic import op
|
|
5
|
+
|
|
6
|
+
revision = "stk_0008"
|
|
7
|
+
down_revision = "stk_0007"
|
|
8
|
+
branch_labels = None
|
|
9
|
+
depends_on = None
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def upgrade() -> None:
|
|
13
|
+
op.create_table(
|
|
14
|
+
"stk_message",
|
|
15
|
+
sa.Column("id", sa.Integer(), nullable=False),
|
|
16
|
+
sa.Column("user_id", sa.Integer(), nullable=False),
|
|
17
|
+
sa.Column("payload", sa.Text(), nullable=False),
|
|
18
|
+
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
19
|
+
sa.ForeignKeyConstraint(
|
|
20
|
+
["user_id"],
|
|
21
|
+
["user.id"],
|
|
22
|
+
name=op.f("fk_stk_message_user_id"),
|
|
23
|
+
ondelete="CASCADE",
|
|
24
|
+
),
|
|
25
|
+
sa.PrimaryKeyConstraint("id", name=op.f("pk_stk_message")),
|
|
26
|
+
)
|
|
27
|
+
with op.batch_alter_table("stk_message", schema=None) as batch_op:
|
|
28
|
+
batch_op.create_index(
|
|
29
|
+
batch_op.f("ix_stk_message_created_at"), ["created_at"], unique=False
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def downgrade() -> None:
|
|
34
|
+
with op.batch_alter_table("stk_message", schema=None) as batch_op:
|
|
35
|
+
batch_op.drop_index(batch_op.f("ix_stk_message_created_at"))
|
|
36
|
+
|
|
37
|
+
op.drop_table("stk_message")
|
|
@@ -9,11 +9,12 @@ from stk.notification.models import Notification
|
|
|
9
9
|
from stk.websocket import broadcast
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
async def notify(user_id, title, link=None, kind=None, body=None):
|
|
13
|
-
"""Store a notification for one user
|
|
12
|
+
async def notify(user_id, title, link=None, kind=None, body=None, session=None):
|
|
13
|
+
"""Store a notification for one user and push it to their sockets.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
With `session`, both join that transaction: they land at commit and vanish on
|
|
16
|
+
rollback. Without it, they commit on their own session.
|
|
17
|
+
`link` must be a same-origin path such as `/exports/3`.
|
|
17
18
|
"""
|
|
18
19
|
# The bell navigates to `link`; a `javascript:` or off-site URL would run there.
|
|
19
20
|
# Browsers strip tabs and newlines from URLs, so "/\t/evil" becomes "//evil".
|
|
@@ -23,16 +24,22 @@ async def notify(user_id, title, link=None, kind=None, body=None):
|
|
|
23
24
|
or any(c.isspace() or ord(c) < 0x20 or ord(c) == 0x7F for c in link)
|
|
24
25
|
):
|
|
25
26
|
raise ValueError(f"link must be a same-origin path, got {link!r}")
|
|
27
|
+
row = Notification(user_id=user_id, title=title, link=link, kind=kind, body=body)
|
|
28
|
+
if session is not None:
|
|
29
|
+
await _store(session, row)
|
|
30
|
+
return row
|
|
26
31
|
async with ext.async_session_factory() as db:
|
|
27
|
-
|
|
28
|
-
user_id=user_id, title=title, link=link, kind=kind, body=body
|
|
29
|
-
)
|
|
30
|
-
db.add(row)
|
|
32
|
+
await _store(db, row)
|
|
31
33
|
await db.commit()
|
|
32
|
-
await broadcast({"type": "notification", **row.to_dict()}, user_id)
|
|
33
34
|
return row
|
|
34
35
|
|
|
35
36
|
|
|
37
|
+
async def _store(db, row):
|
|
38
|
+
db.add(row)
|
|
39
|
+
await db.flush() # id and created_at for the pushed copy
|
|
40
|
+
await broadcast({"type": "notification", **row.to_dict()}, row.user_id, db)
|
|
41
|
+
|
|
42
|
+
|
|
36
43
|
def init_app(app):
|
|
37
44
|
from stk.notification.views import bp_notification
|
|
38
45
|
|
|
@@ -39,7 +39,7 @@ Backend:
|
|
|
39
39
|
- `User.from_dict()`, `Activity.register()`, `Session.create_session()` and the auth signal handlers are async.
|
|
40
40
|
- Pagination is manual: `offset().limit()` plus `select(func.count())`. List endpoints return `orjson` via `Response(json.dumps(data), content_type="application/json")`.
|
|
41
41
|
- Mutations arrive as `{item: {...}}`: read `json_data.get("item", {})`.
|
|
42
|
-
- `Activity.register()` stores audit events and does not broadcast. `broadcast()` needs an explicit recipient
|
|
42
|
+
- `Activity.register()` stores audit events and does not broadcast. `broadcast()` needs an explicit recipient; `session=` sends it at commit.
|
|
43
43
|
- SQLite migrations: DDL is not transactional; a new NOT NULL column needs `server_default` in migration and model; keep the constraint naming convention on `Base.metadata`.
|
|
44
44
|
- `stk verify` blocks drops, renames, retypes, and NOT NULL adds without a default in `upgrade()`. A rename is usually a mistaken drop + add from autogenerate; mark a deliberate one with `# destructive: <reason>`.
|
|
45
45
|
- Tests: subclass `TestingConfig` (`stk/settings.py`), never `Config`; `.env` loads at import. Pin any other env-driven switch a test depends on.
|
|
@@ -5,7 +5,13 @@ from datetime import datetime
|
|
|
5
5
|
from uuid import uuid4
|
|
6
6
|
|
|
7
7
|
from quart import g
|
|
8
|
-
from quart_security import
|
|
8
|
+
from quart_security import (
|
|
9
|
+
RoleMixin,
|
|
10
|
+
SecurityState,
|
|
11
|
+
UserMixin,
|
|
12
|
+
hash_password,
|
|
13
|
+
normalize_email,
|
|
14
|
+
)
|
|
9
15
|
from quart_security.password import hash_password_async
|
|
10
16
|
from sqlalchemy import (
|
|
11
17
|
JSON,
|
|
@@ -78,14 +84,14 @@ class User(Base, UserMixin):
|
|
|
78
84
|
|
|
79
85
|
@validates("email")
|
|
80
86
|
def _normalize_email(self, key, value):
|
|
81
|
-
# Login
|
|
82
|
-
# cannot become two accounts that differ
|
|
83
|
-
return value
|
|
87
|
+
# Login normalizes what it is given; store the same form so one mailbox
|
|
88
|
+
# cannot become two accounts that differ by case or Unicode form.
|
|
89
|
+
return normalize_email(value) if value is not None else value
|
|
84
90
|
|
|
85
91
|
@classmethod
|
|
86
92
|
def email_is(cls, email):
|
|
87
93
|
"""Match an email regardless of case, including rows stored before 17.2.1."""
|
|
88
|
-
return func.lower(cls.email) == email
|
|
94
|
+
return func.lower(cls.email) == normalize_email(email)
|
|
89
95
|
|
|
90
96
|
roles = relationship(
|
|
91
97
|
"Role", secondary=roles_users, backref="users", lazy="selectin"
|
|
@@ -135,7 +141,11 @@ class User(Base, UserMixin):
|
|
|
135
141
|
async def from_dict(self, json_dict):
|
|
136
142
|
self.name = json_dict.get("name", self.name)
|
|
137
143
|
self.username = json_dict.get("username", self.username)
|
|
138
|
-
|
|
144
|
+
email = normalize_email(json_dict.get("email", self.email))
|
|
145
|
+
if email != self.email:
|
|
146
|
+
# Reset and confirmation links sent to the old address stop working.
|
|
147
|
+
self.email = email
|
|
148
|
+
self.fs_uniquifier = uuid4().hex
|
|
139
149
|
if "password" in json_dict:
|
|
140
150
|
self.password = await hash_password_async(json_dict["password"])
|
|
141
151
|
self.password_set = True
|
|
@@ -1,28 +1,67 @@
|
|
|
1
|
-
"""Bounded, same-origin WebSockets with periodic session validation.
|
|
1
|
+
"""Bounded, same-origin WebSockets with periodic session validation.
|
|
2
|
+
|
|
3
|
+
Messages travel through the `stk_message` table, so `broadcast` reaches a user's
|
|
4
|
+
sockets from any process: another uvicorn worker, `stk worker`, or `stk shell`.
|
|
5
|
+
Each server process polls the table while it holds sockets.
|
|
6
|
+
"""
|
|
2
7
|
|
|
3
8
|
import asyncio
|
|
4
9
|
import json
|
|
10
|
+
import logging
|
|
5
11
|
import time
|
|
12
|
+
from datetime import datetime, timedelta
|
|
6
13
|
|
|
7
14
|
from quart import Blueprint, current_app, g, session, websocket
|
|
8
15
|
from quart_security import SecurityState, current_user
|
|
9
|
-
from sqlalchemy import select
|
|
16
|
+
from sqlalchemy import Column, DateTime, ForeignKey, Integer, Text, delete, select
|
|
10
17
|
|
|
11
18
|
import stk.extensions as ext
|
|
19
|
+
from stk.extensions import Base
|
|
12
20
|
from stk.user.models import User
|
|
13
21
|
|
|
22
|
+
# ponytail: polling, so delivery lags up to POLL seconds; on Postgres add a
|
|
23
|
+
# LISTEN wake-up to the same loop if that lag is noticed.
|
|
24
|
+
POLL = 0.25
|
|
25
|
+
# Rows are re-read for this long, so one that commits after a later id is still
|
|
26
|
+
# delivered (Postgres ids can commit out of order); seen ids are skipped.
|
|
27
|
+
WINDOW = timedelta(seconds=10)
|
|
28
|
+
RETENTION = timedelta(minutes=1)
|
|
29
|
+
|
|
14
30
|
ws_bp = Blueprint("ws", __name__)
|
|
15
31
|
_clients: dict[str, set[asyncio.Queue]] = {}
|
|
32
|
+
_poller: asyncio.Task | None = None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Message(Base):
|
|
36
|
+
__tablename__ = "stk_message"
|
|
37
|
+
|
|
38
|
+
id = Column(Integer, primary_key=True)
|
|
39
|
+
user_id = Column(Integer, ForeignKey("user.id", ondelete="CASCADE"), nullable=False)
|
|
40
|
+
payload = Column(Text, nullable=False)
|
|
41
|
+
created_at = Column(DateTime, default=datetime.now, nullable=False, index=True)
|
|
16
42
|
|
|
17
43
|
|
|
18
44
|
def get_connected_users() -> list[str]:
|
|
19
45
|
return list(_clients)
|
|
20
46
|
|
|
21
47
|
|
|
22
|
-
async def broadcast(message: dict, user_id
|
|
23
|
-
"""Send only to the explicitly selected user.
|
|
24
|
-
|
|
25
|
-
|
|
48
|
+
async def broadcast(message: dict, user_id, session=None):
|
|
49
|
+
"""Send only to the explicitly selected user, from any process.
|
|
50
|
+
|
|
51
|
+
With `session`, the message joins that transaction: it goes out at commit and
|
|
52
|
+
not at all on rollback. Without it, it is committed on its own session.
|
|
53
|
+
"""
|
|
54
|
+
row = Message(user_id=int(user_id), payload=json.dumps(message))
|
|
55
|
+
if session is not None:
|
|
56
|
+
session.add(row)
|
|
57
|
+
return
|
|
58
|
+
async with ext.async_session_factory() as db:
|
|
59
|
+
db.add(row)
|
|
60
|
+
await db.commit()
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _deliver(user_id: str, payload: str):
|
|
64
|
+
for queue in _clients.get(user_id, set()):
|
|
26
65
|
try:
|
|
27
66
|
queue.put_nowait(payload)
|
|
28
67
|
except asyncio.QueueFull:
|
|
@@ -32,13 +71,61 @@ async def broadcast(message: dict, user_id: str):
|
|
|
32
71
|
queue.put_nowait(None)
|
|
33
72
|
|
|
34
73
|
|
|
74
|
+
async def _recent_ids(db):
|
|
75
|
+
since = datetime.now() - WINDOW
|
|
76
|
+
return (
|
|
77
|
+
await db.execute(
|
|
78
|
+
select(Message.id, Message.user_id).where(Message.created_at > since)
|
|
79
|
+
)
|
|
80
|
+
).all()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
async def _poll():
|
|
84
|
+
"""Fan new rows out to this process's sockets until the last one closes."""
|
|
85
|
+
global _poller
|
|
86
|
+
try:
|
|
87
|
+
async with ext.async_session_factory() as db:
|
|
88
|
+
# Only rows sent from now on: a reconnecting tab must not replay.
|
|
89
|
+
seen = {row.id: time.monotonic() for row in await _recent_ids(db)}
|
|
90
|
+
trimmed = time.monotonic()
|
|
91
|
+
while _clients:
|
|
92
|
+
await asyncio.sleep(POLL)
|
|
93
|
+
now = time.monotonic()
|
|
94
|
+
async with ext.async_session_factory() as db:
|
|
95
|
+
# Every new row counts as seen, so a user who connects later does
|
|
96
|
+
# not receive what was sent before.
|
|
97
|
+
fresh = [row for row in await _recent_ids(db) if row.id not in seen]
|
|
98
|
+
seen.update((row.id, now) for row in fresh)
|
|
99
|
+
wanted = [row.id for row in fresh if str(row.user_id) in _clients]
|
|
100
|
+
rows = []
|
|
101
|
+
if wanted:
|
|
102
|
+
query = select(Message.user_id, Message.payload)
|
|
103
|
+
query = query.where(Message.id.in_(wanted)).order_by(Message.id)
|
|
104
|
+
rows = (await db.execute(query)).all()
|
|
105
|
+
if now - trimmed > RETENTION.total_seconds():
|
|
106
|
+
cutoff = datetime.now() - RETENTION
|
|
107
|
+
await db.execute(delete(Message).where(Message.created_at < cutoff))
|
|
108
|
+
await db.commit()
|
|
109
|
+
trimmed = now
|
|
110
|
+
for row in rows:
|
|
111
|
+
_deliver(str(row.user_id), row.payload)
|
|
112
|
+
horizon = now - 2 * WINDOW.total_seconds()
|
|
113
|
+
seen = {id: at for id, at in seen.items() if at > horizon}
|
|
114
|
+
except Exception:
|
|
115
|
+
# Open sockets stop receiving until the next one connects and restarts this.
|
|
116
|
+
logging.getLogger(__name__).exception("websocket message poller failed")
|
|
117
|
+
raise
|
|
118
|
+
finally:
|
|
119
|
+
_poller = None
|
|
120
|
+
|
|
121
|
+
|
|
35
122
|
@ws_bp.websocket("/ws")
|
|
36
123
|
async def ws_endpoint():
|
|
37
124
|
db = g.pop("db_session", None)
|
|
38
125
|
if db is not None:
|
|
39
126
|
await db.close()
|
|
40
127
|
allowed = current_app.config.get("STK_WS_ALLOWED_ORIGINS") or [
|
|
41
|
-
current_app.config.get("STK_PUBLIC_URL")
|
|
128
|
+
(current_app.config.get("STK_PUBLIC_URL") or "").rstrip("/")
|
|
42
129
|
or websocket.host_url.replace("ws://", "http://", 1)
|
|
43
130
|
.replace("wss://", "https://", 1)
|
|
44
131
|
.rstrip("/")
|
|
@@ -63,6 +150,9 @@ async def ws_endpoint():
|
|
|
63
150
|
return
|
|
64
151
|
queue = asyncio.Queue(maxsize=current_app.config.get("STK_WS_QUEUE_SIZE", 32))
|
|
65
152
|
_clients.setdefault(user_id, set()).add(queue)
|
|
153
|
+
global _poller
|
|
154
|
+
if _poller is None:
|
|
155
|
+
_poller = asyncio.create_task(_poll())
|
|
66
156
|
|
|
67
157
|
async def check_authorization():
|
|
68
158
|
async with ext.async_session_factory() as db:
|
|
@@ -86,5 +86,21 @@ class DatabaseCommandTest(unittest.TestCase):
|
|
|
86
86
|
load.assert_called()
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
class RunCommandTest(unittest.TestCase):
|
|
90
|
+
def test_run_on_a_taken_port_names_the_holder(self):
|
|
91
|
+
import os
|
|
92
|
+
import socket
|
|
93
|
+
|
|
94
|
+
with socket.socket() as held:
|
|
95
|
+
held.bind(("127.0.0.1", 0))
|
|
96
|
+
held.listen()
|
|
97
|
+
port = held.getsockname()[1]
|
|
98
|
+
result = CliRunner().invoke(main, ["run", "--port", str(port)])
|
|
99
|
+
|
|
100
|
+
self.assertNotEqual(result.exit_code, 0)
|
|
101
|
+
self.assertIn(f"port {port} is in use", result.output)
|
|
102
|
+
self.assertIn(f"pid {os.getpid()}", result.output)
|
|
103
|
+
|
|
104
|
+
|
|
89
105
|
async def _done():
|
|
90
106
|
return None
|
|
@@ -128,6 +128,64 @@ class NotificationTests(unittest.IsolatedAsyncioTestCase):
|
|
|
128
128
|
with self.assertRaises(TimeoutError):
|
|
129
129
|
await asyncio.wait_for(bob_ws.receive(), 0.2)
|
|
130
130
|
|
|
131
|
+
async def test_socket_opened_later_does_not_replay_earlier_pushes(self):
|
|
132
|
+
alice, bob = (
|
|
133
|
+
await self.client("alice@example.com"),
|
|
134
|
+
await self.client("bob@example.com"),
|
|
135
|
+
)
|
|
136
|
+
origin = {"Origin": "http://localhost"}
|
|
137
|
+
async with alice.websocket("/ws", headers=origin) as alice_ws:
|
|
138
|
+
await alice_ws.receive()
|
|
139
|
+
await notify(self.bob, "Before Bob connected")
|
|
140
|
+
await asyncio.sleep(0.5) # the running poller has passed it
|
|
141
|
+
async with bob.websocket("/ws", headers=origin) as bob_ws:
|
|
142
|
+
await bob_ws.receive()
|
|
143
|
+
with self.assertRaises(TimeoutError):
|
|
144
|
+
await asyncio.wait_for(bob_ws.receive(), 0.6)
|
|
145
|
+
|
|
146
|
+
async def test_push_from_another_process_reaches_the_socket(self):
|
|
147
|
+
"""`stk worker` and other uvicorn workers are separate processes."""
|
|
148
|
+
import sys
|
|
149
|
+
import tempfile
|
|
150
|
+
from pathlib import Path
|
|
151
|
+
|
|
152
|
+
await ext.engine.dispose()
|
|
153
|
+
folder = tempfile.TemporaryDirectory()
|
|
154
|
+
self.addCleanup(folder.cleanup)
|
|
155
|
+
uri = f"sqlite+aiosqlite:///{Path(folder.name) / 'shared.db'}"
|
|
156
|
+
config = type(
|
|
157
|
+
"SharedConfig", (TestingConfig,), {"SQLALCHEMY_DATABASE_URI": uri}
|
|
158
|
+
)
|
|
159
|
+
self.app = Stk(__name__, config=config, extensions=[stk.notification])
|
|
160
|
+
async with ext.engine.begin() as conn:
|
|
161
|
+
await conn.run_sync(Base.metadata.create_all)
|
|
162
|
+
async with ext.async_session_factory() as db:
|
|
163
|
+
user = User(
|
|
164
|
+
email="carol@example.com",
|
|
165
|
+
active=True,
|
|
166
|
+
password=hash_password("Password123!", app=self.app),
|
|
167
|
+
)
|
|
168
|
+
db.add(user)
|
|
169
|
+
await db.commit()
|
|
170
|
+
carol = await self.client("carol@example.com")
|
|
171
|
+
script = (
|
|
172
|
+
"import asyncio, sys\n"
|
|
173
|
+
"from stk.app import Stk\n"
|
|
174
|
+
"from stk.settings import TestingConfig\n"
|
|
175
|
+
"from stk.websocket import broadcast\n"
|
|
176
|
+
"C = type('C', (TestingConfig,), {'SQLALCHEMY_DATABASE_URI': sys.argv[1]})\n"
|
|
177
|
+
"Stk('other', config=C)\n"
|
|
178
|
+
"asyncio.run(broadcast({'type': 'progress', 'done': 40}, int(sys.argv[2])))\n"
|
|
179
|
+
)
|
|
180
|
+
async with carol.websocket("/ws", headers={"Origin": "http://localhost"}) as ws:
|
|
181
|
+
await ws.receive()
|
|
182
|
+
other = await asyncio.create_subprocess_exec(
|
|
183
|
+
sys.executable, "-c", script, uri, str(user.id)
|
|
184
|
+
)
|
|
185
|
+
self.assertEqual(await other.wait(), 0)
|
|
186
|
+
message = json.loads(await asyncio.wait_for(ws.receive(), 2))
|
|
187
|
+
self.assertEqual(message, {"type": "progress", "done": 40})
|
|
188
|
+
|
|
131
189
|
|
|
132
190
|
if __name__ == "__main__":
|
|
133
191
|
unittest.main()
|