@kromatv/sdk 0.1.40-canary.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/README.md +80 -0
- package/dist/cli.js +2523 -0
- package/package.json +78 -0
- package/rust/Cargo.toml +3 -0
- package/rust/kroma-db/Cargo.toml +27 -0
- package/rust/kroma-db/src/accounts/access_tokens.rs +197 -0
- package/rust/kroma-db/src/accounts/credentials.rs +97 -0
- package/rust/kroma-db/src/accounts/invites.rs +136 -0
- package/rust/kroma-db/src/accounts/preferences.rs +100 -0
- package/rust/kroma-db/src/accounts/resets.rs +202 -0
- package/rust/kroma-db/src/accounts/sessions.rs +182 -0
- package/rust/kroma-db/src/accounts/test_support.rs +14 -0
- package/rust/kroma-db/src/accounts/verifications.rs +185 -0
- package/rust/kroma-db/src/accounts.rs +244 -0
- package/rust/kroma-db/src/admin/metrics.rs +201 -0
- package/rust/kroma-db/src/admin/play_history.rs +361 -0
- package/rust/kroma-db/src/admin/play_sort.rs +113 -0
- package/rust/kroma-db/src/admin/stats.rs +108 -0
- package/rust/kroma-db/src/admin/test_support.rs +83 -0
- package/rust/kroma-db/src/admin/watch_stats.rs +458 -0
- package/rust/kroma-db/src/admin.rs +226 -0
- package/rust/kroma-db/src/audio_analysis.rs +253 -0
- package/rust/kroma-db/src/backup/module_stores.rs +204 -0
- package/rust/kroma-db/src/backup/rows.rs +155 -0
- package/rust/kroma-db/src/backup/test_support.rs +61 -0
- package/rust/kroma-db/src/backup.rs +306 -0
- package/rust/kroma-db/src/catalog_query/find_titles.rs +316 -0
- package/rust/kroma-db/src/catalog_query/test_support.rs +88 -0
- package/rust/kroma-db/src/catalog_query.rs +198 -0
- package/rust/kroma-db/src/chunked.rs +36 -0
- package/rust/kroma-db/src/core_tables.rs +99 -0
- package/rust/kroma-db/src/curated.rs +192 -0
- package/rust/kroma-db/src/downloaded_subs.rs +136 -0
- package/rust/kroma-db/src/downloads.rs +219 -0
- package/rust/kroma-db/src/grant/escapes/schema.rs +120 -0
- package/rust/kroma-db/src/grant/escapes/statements.rs +170 -0
- package/rust/kroma-db/src/grant/escapes.rs +141 -0
- package/rust/kroma-db/src/grant/tests.rs +255 -0
- package/rust/kroma-db/src/grant.rs +203 -0
- package/rust/kroma-db/src/home/genre_guard.rs +249 -0
- package/rust/kroma-db/src/home/hydration.rs +126 -0
- package/rust/kroma-db/src/home/test_support.rs +60 -0
- package/rust/kroma-db/src/home.rs +244 -0
- package/rust/kroma-db/src/hydrate.rs +296 -0
- package/rust/kroma-db/src/ingest/metadata.rs +648 -0
- package/rust/kroma-db/src/ingest/probe.rs +171 -0
- package/rust/kroma-db/src/ingest/probe_result.rs +178 -0
- package/rust/kroma-db/src/ingest/scanned_files.rs +235 -0
- package/rust/kroma-db/src/ingest/sync.rs +291 -0
- package/rust/kroma-db/src/ingest/test_support.rs +114 -0
- package/rust/kroma-db/src/ingest.rs +20 -0
- package/rust/kroma-db/src/jobs.rs +269 -0
- package/rust/kroma-db/src/lib.rs +97 -0
- package/rust/kroma-db/src/library.rs +66 -0
- package/rust/kroma-db/src/localize/items.rs +303 -0
- package/rust/kroma-db/src/localize/shows.rs +192 -0
- package/rust/kroma-db/src/localize/test_support.rs +91 -0
- package/rust/kroma-db/src/localize.rs +105 -0
- package/rust/kroma-db/src/markers.rs +203 -0
- package/rust/kroma-db/src/media/person.rs +213 -0
- package/rust/kroma-db/src/media/show_detail.rs +186 -0
- package/rust/kroma-db/src/media/shows.rs +202 -0
- package/rust/kroma-db/src/media/splash.rs +199 -0
- package/rust/kroma-db/src/media/test_support.rs +31 -0
- package/rust/kroma-db/src/media.rs +296 -0
- package/rust/kroma-db/src/metadata_core.rs +348 -0
- package/rust/kroma-db/src/notifications/digest.rs +143 -0
- package/rust/kroma-db/src/notifications/preferences.rs +138 -0
- package/rust/kroma-db/src/notifications/read_state.rs +167 -0
- package/rust/kroma-db/src/notifications/test_support.rs +50 -0
- package/rust/kroma-db/src/notifications.rs +232 -0
- package/rust/kroma-db/src/passkeys.rs +163 -0
- package/rust/kroma-db/src/pipeline/ops/drain.rs +266 -0
- package/rust/kroma-db/src/pipeline/ops/reconcile.rs +274 -0
- package/rust/kroma-db/src/pipeline/ops/test_support.rs +48 -0
- package/rust/kroma-db/src/pipeline/ops.rs +49 -0
- package/rust/kroma-db/src/pipeline/query/elements.rs +200 -0
- package/rust/kroma-db/src/pipeline/query/test_support.rs +23 -0
- package/rust/kroma-db/src/pipeline/query.rs +255 -0
- package/rust/kroma-db/src/pipeline/tests.rs +319 -0
- package/rust/kroma-db/src/pipeline.rs +26 -0
- package/rust/kroma-db/src/playback/continue_watching.rs +289 -0
- package/rust/kroma-db/src/playback/on_deck.rs +53 -0
- package/rust/kroma-db/src/playback/show_progress.rs +230 -0
- package/rust/kroma-db/src/playback/test_support.rs +55 -0
- package/rust/kroma-db/src/playback/up_next.rs +208 -0
- package/rust/kroma-db/src/playback/watch_state.rs +129 -0
- package/rust/kroma-db/src/playback.rs +196 -0
- package/rust/kroma-db/src/pool.rs +117 -0
- package/rust/kroma-db/src/push_subs.rs +323 -0
- package/rust/kroma-db/src/reports.rs +231 -0
- package/rust/kroma-db/src/requests/availability.rs +211 -0
- package/rust/kroma-db/src/requests/calendar.rs +221 -0
- package/rust/kroma-db/src/requests/gaps.rs +213 -0
- package/rust/kroma-db/src/requests/search_queue.rs +352 -0
- package/rust/kroma-db/src/requests/tests.rs +289 -0
- package/rust/kroma-db/src/requests/wanted.rs +351 -0
- package/rust/kroma-db/src/requests.rs +245 -0
- package/rust/kroma-db/src/rows.rs +190 -0
- package/rust/kroma-db/src/schema/ddl.rs +678 -0
- package/rust/kroma-db/src/schema/migrations.rs +261 -0
- package/rust/kroma-db/src/schema.rs +273 -0
- package/rust/kroma-db/src/suggest.rs +129 -0
- package/rust/kroma-db/src/taste.rs +77 -0
- package/rust/kroma-db/src/testing.rs +63 -0
- package/rust/kroma-db/src/tmdb_pin.rs +133 -0
- package/rust/kroma-db/src/translations.rs +569 -0
- package/rust/kroma-db/src/vectors/recommendations.rs +164 -0
- package/rust/kroma-db/src/vectors/search.rs +213 -0
- package/rust/kroma-db/src/vectors/test_support.rs +31 -0
- package/rust/kroma-db/src/vectors.rs +161 -0
- package/rust/kroma-domain/Cargo.toml +17 -0
- package/rust/kroma-domain/src/accounts.rs +181 -0
- package/rust/kroma-domain/src/admin.rs +197 -0
- package/rust/kroma-domain/src/cast.rs +178 -0
- package/rust/kroma-domain/src/crash.rs +48 -0
- package/rust/kroma-domain/src/jobs.rs +119 -0
- package/rust/kroma-domain/src/lib.rs +44 -0
- package/rust/kroma-domain/src/library.rs +21 -0
- package/rust/kroma-domain/src/matching/mod.rs +293 -0
- package/rust/kroma-domain/src/matching/normalize.rs +193 -0
- package/rust/kroma-domain/src/media.rs +297 -0
- package/rust/kroma-domain/src/metadata.rs +389 -0
- package/rust/kroma-domain/src/naming/marker.rs +215 -0
- package/rust/kroma-domain/src/naming/mod.rs +283 -0
- package/rust/kroma-domain/src/naming/title.rs +349 -0
- package/rust/kroma-domain/src/notifications/action.rs +50 -0
- package/rust/kroma-domain/src/notifications/event.rs +225 -0
- package/rust/kroma-domain/src/notifications/mod.rs +18 -0
- package/rust/kroma-domain/src/notifications/param.rs +90 -0
- package/rust/kroma-domain/src/notifications/spec.rs +178 -0
- package/rust/kroma-domain/src/notifications/view.rs +55 -0
- package/rust/kroma-domain/src/people.rs +286 -0
- package/rust/kroma-domain/src/pipeline.rs +114 -0
- package/rust/kroma-domain/src/playback.rs +39 -0
- package/rust/kroma-domain/src/push.rs +163 -0
- package/rust/kroma-domain/src/reports.rs +213 -0
- package/rust/kroma-domain/src/requests/discover.rs +102 -0
- package/rust/kroma-domain/src/requests/ledger.rs +129 -0
- package/rust/kroma-domain/src/requests/mod.rs +238 -0
- package/rust/kroma-domain/src/section.rs +44 -0
- package/rust/kroma-domain/src/slug.rs +165 -0
- package/rust/kroma-http/Cargo.toml +20 -0
- package/rust/kroma-http/examples/seam-bench.rs +73 -0
- package/rust/kroma-http/src/builder.rs +35 -0
- package/rust/kroma-http/src/config.rs +50 -0
- package/rust/kroma-http/src/curl.rs +131 -0
- package/rust/kroma-http/src/fetch.rs +226 -0
- package/rust/kroma-http/src/lib.rs +25 -0
- package/rust/kroma-http/src/loopback/mod.rs +220 -0
- package/rust/kroma-http/src/loopback/tcp.rs +182 -0
- package/rust/kroma-http/src/loopback/transport.rs +42 -0
- package/rust/kroma-http/src/response.rs +130 -0
- package/rust/kroma-module-host/Cargo.toml +36 -0
- package/rust/kroma-module-host/src/auth.rs +221 -0
- package/rust/kroma-module-host/src/host_ctx.rs +382 -0
- package/rust/kroma-module-host/src/host_token.rs +147 -0
- package/rust/kroma-module-host/src/lib.rs +141 -0
- package/rust/kroma-module-host/src/module.rs +115 -0
- package/rust/kroma-module-host/src/port.rs +163 -0
- package/rust/kroma-module-host/src/storage.rs +97 -0
- package/rust/kroma-module-host/src/test_serve.rs +33 -0
- package/rust/kroma-module-host/src/testing/log.rs +145 -0
- package/rust/kroma-module-host/src/testing/mod.rs +72 -0
- package/rust/kroma-module-host/src/testing/recording.rs +209 -0
- package/rust/kroma-module-host/src/testing/stub.rs +592 -0
- package/rust/kroma-module-macros/Cargo.toml +12 -0
- package/rust/kroma-module-macros/src/lib.rs +148 -0
- package/rust/kroma-module-manifest/Cargo.toml +15 -0
- package/rust/kroma-module-manifest/src/compat.rs +157 -0
- package/rust/kroma-module-manifest/src/embedded.rs +160 -0
- package/rust/kroma-module-manifest/src/event.rs +74 -0
- package/rust/kroma-module-manifest/src/lib.rs +57 -0
- package/rust/kroma-module-manifest/src/manifest.rs +548 -0
- package/rust/kroma-module-manifest/src/registry.rs +626 -0
- package/rust/kroma-module-runtime/Cargo.toml +33 -0
- package/rust/kroma-module-runtime/src/lib.rs +743 -0
- package/rust/kroma-module-sdk/Cargo.toml +49 -0
- package/rust/kroma-module-sdk/src/lib.rs +70 -0
- package/rust/kroma-primitives/Cargo.toml +12 -0
- package/rust/kroma-primitives/src/lib.rs +101 -0
- package/rust/kroma-testing/Cargo.toml +10 -0
- package/rust/kroma-testing/src/lib.rs +72 -0
- package/templates/base/README.md +14 -0
- package/templates/base/_gitignore +4 -0
- package/templates/base/icon.svg +1 -0
- package/templates/base/locales/en.json +7 -0
- package/templates/base/locales/fr.json +7 -0
- package/templates/server/.cargo/config.toml +2 -0
- package/templates/server/rust-toolchain.toml +3 -0
- package/templates/server/server/Cargo.toml +37 -0
- package/templates/server/server/src/bin/module.rs +6 -0
- package/templates/server/server/src/lib.rs +43 -0
- package/templates/ui/ui/src/__PAGE__.tsx +22 -0
- package/templates/ui/ui/src/module.tsx +17 -0
- package/templates/ui/ui/src/schemas.ts +6 -0
- package/tsconfig.module.json +110 -0
- package/types/client/src/api/accounts/client.d.ts +291 -0
- package/types/client/src/api/accounts/ids.d.ts +13 -0
- package/types/client/src/api/accounts/index.d.ts +6 -0
- package/types/client/src/api/accounts/passkeys.d.ts +79 -0
- package/types/client/src/api/accounts/quick-connect.d.ts +23 -0
- package/types/client/src/api/accounts/remembered.d.ts +66 -0
- package/types/client/src/api/accounts/rules.d.ts +9 -0
- package/types/client/src/api/accounts/schemas.d.ts +214 -0
- package/types/client/src/api/admin/backup.d.ts +22 -0
- package/types/client/src/api/admin/client.d.ts +407 -0
- package/types/client/src/api/admin/index.d.ts +7 -0
- package/types/client/src/api/admin/logs.d.ts +24 -0
- package/types/client/src/api/admin/metrics.d.ts +231 -0
- package/types/client/src/api/admin/notifications.d.ts +47 -0
- package/types/client/src/api/admin/settings.d.ts +50 -0
- package/types/client/src/api/admin/stats.d.ts +257 -0
- package/types/client/src/api/admin/users.d.ts +98 -0
- package/types/client/src/api/cast/client.d.ts +209 -0
- package/types/client/src/api/cast/ids.d.ts +4 -0
- package/types/client/src/api/cast/index.d.ts +3 -0
- package/types/client/src/api/cast/schemas.d.ts +565 -0
- package/types/client/src/api/diagnostics/client.d.ts +13 -0
- package/types/client/src/api/diagnostics/index.d.ts +2 -0
- package/types/client/src/api/diagnostics/schemas.d.ts +29 -0
- package/types/client/src/api/discover.d.ts +5 -0
- package/types/client/src/api/discover.web.d.ts +5 -0
- package/types/client/src/api/discovery/client.d.ts +115 -0
- package/types/client/src/api/discovery/index.d.ts +2 -0
- package/types/client/src/api/discovery/schemas.d.ts +175 -0
- package/types/client/src/api/events/index.d.ts +2 -0
- package/types/client/src/api/events/schemas.d.ts +371 -0
- package/types/client/src/api/events/socket.d.ts +42 -0
- package/types/client/src/api/handoff/client.d.ts +68 -0
- package/types/client/src/api/handoff/ids.d.ts +4 -0
- package/types/client/src/api/handoff/index.d.ts +3 -0
- package/types/client/src/api/handoff/schemas.d.ts +93 -0
- package/types/client/src/api/jobs/client.d.ts +96 -0
- package/types/client/src/api/jobs/ids.d.ts +5 -0
- package/types/client/src/api/jobs/index.d.ts +3 -0
- package/types/client/src/api/jobs/schemas.d.ts +168 -0
- package/types/client/src/api/library/client.d.ts +45 -0
- package/types/client/src/api/library/index.d.ts +2 -0
- package/types/client/src/api/library/schemas.d.ts +28 -0
- package/types/client/src/api/llm/client.d.ts +37 -0
- package/types/client/src/api/llm/ids.d.ts +3 -0
- package/types/client/src/api/llm/index.d.ts +3 -0
- package/types/client/src/api/llm/schemas.d.ts +74 -0
- package/types/client/src/api/media/artwork-scale.d.ts +18 -0
- package/types/client/src/api/media/artwork.d.ts +31 -0
- package/types/client/src/api/media/client.d.ts +2160 -0
- package/types/client/src/api/media/credits.d.ts +46 -0
- package/types/client/src/api/media/ids.d.ts +12 -0
- package/types/client/src/api/media/index.d.ts +7 -0
- package/types/client/src/api/media/rematch.d.ts +31 -0
- package/types/client/src/api/media/schemas.d.ts +1607 -0
- package/types/client/src/api/media/search.d.ts +1044 -0
- package/types/client/src/api/media/tracks.d.ts +152 -0
- package/types/client/src/api/modules/client.d.ts +38 -0
- package/types/client/src/api/modules/ids.d.ts +3 -0
- package/types/client/src/api/modules/index.d.ts +5 -0
- package/types/client/src/api/modules/module-api.d.ts +23 -0
- package/types/client/src/api/modules/schemas.d.ts +74 -0
- package/types/client/src/api/modules/store.d.ts +226 -0
- package/types/client/src/api/notifications/capability.d.ts +36 -0
- package/types/client/src/api/notifications/client.d.ts +79 -0
- package/types/client/src/api/notifications/ids.d.ts +3 -0
- package/types/client/src/api/notifications/index.d.ts +4 -0
- package/types/client/src/api/notifications/push.d.ts +18 -0
- package/types/client/src/api/notifications/schemas.d.ts +235 -0
- package/types/client/src/api/pipeline/client.d.ts +126 -0
- package/types/client/src/api/pipeline/index.d.ts +2 -0
- package/types/client/src/api/pipeline/schemas.d.ts +139 -0
- package/types/client/src/api/playback/client.d.ts +681 -0
- package/types/client/src/api/playback/ids.d.ts +3 -0
- package/types/client/src/api/playback/index.d.ts +3 -0
- package/types/client/src/api/playback/schemas.d.ts +38 -0
- package/types/client/src/api/reports/client.d.ts +117 -0
- package/types/client/src/api/reports/ids.d.ts +3 -0
- package/types/client/src/api/reports/index.d.ts +3 -0
- package/types/client/src/api/reports/schemas.d.ts +144 -0
- package/types/client/src/api/requests/acquisition.d.ts +240 -0
- package/types/client/src/api/requests/client.d.ts +301 -0
- package/types/client/src/api/requests/ids.d.ts +7 -0
- package/types/client/src/api/requests/index.d.ts +4 -0
- package/types/client/src/api/requests/schemas.d.ts +162 -0
- package/types/client/src/api/subtitles/client.d.ts +48 -0
- package/types/client/src/api/subtitles/ids.d.ts +5 -0
- package/types/client/src/api/subtitles/index.d.ts +3 -0
- package/types/client/src/api/subtitles/schemas.d.ts +78 -0
- package/types/client/src/core/client.d.ts +17 -0
- package/types/client/src/core/http/api-error.d.ts +36 -0
- package/types/client/src/core/http/body.d.ts +1 -0
- package/types/client/src/core/http/concurrency.d.ts +8 -0
- package/types/client/src/core/http/index.d.ts +6 -0
- package/types/client/src/core/http/path.d.ts +10 -0
- package/types/client/src/core/http/preconnect.d.ts +2 -0
- package/types/client/src/core/http/query.d.ts +9 -0
- package/types/client/src/core/http/request-context.d.ts +94 -0
- package/types/client/src/core/http/user-agent.d.ts +7 -0
- package/types/client/src/core/ids/ids.d.ts +13 -0
- package/types/client/src/core/ids/index.d.ts +1 -0
- package/types/client/src/core/index.d.ts +4 -0
- package/types/client/src/core/session/index.d.ts +3 -0
- package/types/client/src/core/session/locale.d.ts +6 -0
- package/types/client/src/core/session/storage.d.ts +32 -0
- package/types/client/src/core/session/token.d.ts +19 -0
- package/types/client/src/index.d.ts +3 -0
- package/types/client/src/kroma-client.d.ts +49 -0
- package/types/client/src/query/index.d.ts +35 -0
- package/types/core/src/airdate.d.ts +21 -0
- package/types/core/src/browse.d.ts +45 -0
- package/types/core/src/compat.d.ts +9 -0
- package/types/core/src/discover.d.ts +31 -0
- package/types/core/src/format.d.ts +63 -0
- package/types/core/src/genre-art.d.ts +21 -0
- package/types/core/src/genre-table.d.ts +117 -0
- package/types/core/src/genre.d.ts +42 -0
- package/types/core/src/handoff/beacon.d.ts +39 -0
- package/types/core/src/handoff/grant.d.ts +20 -0
- package/types/core/src/handoff/index.d.ts +8 -0
- package/types/core/src/handoff/nearby.d.ts +17 -0
- package/types/core/src/handoff/sources.d.ts +110 -0
- package/types/core/src/health-probe.d.ts +19 -0
- package/types/core/src/hevc/audio-support.d.ts +47 -0
- package/types/core/src/hevc/capabilities.d.ts +63 -0
- package/types/core/src/hevc/directplay.d.ts +70 -0
- package/types/core/src/hevc/engine.d.ts +29 -0
- package/types/core/src/hevc.d.ts +4 -0
- package/types/core/src/i18n.d.ts +2381 -0
- package/types/core/src/index.d.ts +25 -0
- package/types/core/src/intl.d.ts +28 -0
- package/types/core/src/lang-table.d.ts +11 -0
- package/types/core/src/lang.d.ts +59 -0
- package/types/core/src/local-ip.d.ts +2 -0
- package/types/core/src/locales/catalogs.d.ts +2 -0
- package/types/core/src/locales/catalogs.web.d.ts +3 -0
- package/types/core/src/locales/default-locale.d.ts +3 -0
- package/types/core/src/match.d.ts +14 -0
- package/types/core/src/notification-labels.d.ts +47 -0
- package/types/core/src/people.d.ts +33 -0
- package/types/core/src/permissions.d.ts +10 -0
- package/types/core/src/person-facts.d.ts +23 -0
- package/types/core/src/platform.d.ts +7 -0
- package/types/core/src/playback-buffer.d.ts +64 -0
- package/types/core/src/playback-stall.d.ts +86 -0
- package/types/core/src/player.d.ts +22 -0
- package/types/core/src/push-labels.d.ts +6 -0
- package/types/core/src/react/handoff-picker.d.ts +52 -0
- package/types/core/src/react/index.d.ts +6 -0
- package/types/core/src/react/lang-prefs.d.ts +35 -0
- package/types/core/src/react/nearby-tvs.d.ts +31 -0
- package/types/core/src/remote.d.ts +26 -0
- package/types/core/src/server-origin.d.ts +12 -0
- package/types/core/src/slug.d.ts +4 -0
- package/types/core/src/subtitles.d.ts +20 -0
- package/types/i18n/src/announce.d.ts +15 -0
- package/types/i18n/src/catalog-types.d.ts +7 -0
- package/types/i18n/src/chain.d.ts +22 -0
- package/types/i18n/src/define.d.ts +39 -0
- package/types/i18n/src/dev-overrides.d.ts +39 -0
- package/types/i18n/src/i18n.d.ts +61 -0
- package/types/i18n/src/index.d.ts +11 -0
- package/types/i18n/src/interpolate.d.ts +14 -0
- package/types/i18n/src/layout.d.ts +18 -0
- package/types/i18n/src/locales.d.ts +12 -0
- package/types/i18n/src/namespaces.d.ts +37 -0
- package/types/i18n/src/nest.d.ts +17 -0
- package/types/i18n/src/plural.d.ts +20 -0
- package/types/i18n/src/react/context.d.ts +37 -0
- package/types/i18n/src/react/index.d.ts +2 -0
- package/types/i18n/src/react/provider.d.ts +14 -0
- package/types/i18n/src/registry.d.ts +36 -0
- package/types/i18n/src/store.d.ts +46 -0
- package/types/i18n/src/types.d.ts +30 -0
- package/types/module-sdk/src/admin/context.d.ts +20 -0
- package/types/module-sdk/src/admin/denied.d.ts +1 -0
- package/types/module-sdk/src/admin/engines.d.ts +35 -0
- package/types/module-sdk/src/admin/hooks.d.ts +39 -0
- package/types/module-sdk/src/admin/page-states.d.ts +27 -0
- package/types/module-sdk/src/admin/settings.d.ts +9 -0
- package/types/module-sdk/src/bus.d.ts +8 -0
- package/types/module-sdk/src/contracts.d.ts +6 -0
- package/types/module-sdk/src/define.d.ts +38 -0
- package/types/module-sdk/src/events.d.ts +11 -0
- package/types/module-sdk/src/host.d.ts +32 -0
- package/types/module-sdk/src/icon.d.ts +1 -0
- package/types/module-sdk/src/index.d.ts +35 -0
- package/types/module-sdk/src/module.d.ts +83 -0
- package/types/module-sdk/src/registry.d.ts +63 -0
- package/types/module-sdk/src/scope.d.ts +23 -0
- package/types/module-sdk/src/shared.d.ts +21 -0
- package/types/module-sdk/src/slot.d.ts +34 -0
- package/types/module-sdk/src/types.d.ts +39 -0
- package/types/module-sdk/src/ui/table.d.ts +88 -0
- package/types/module-sdk/src/use-sorted-table.d.ts +56 -0
- package/types/registry/src/build.d.ts +16 -0
- package/types/registry/src/client.d.ts +23 -0
- package/types/registry/src/documents/index.d.ts +6 -0
- package/types/registry/src/documents/v1.d.ts +197 -0
- package/types/registry/src/index.d.ts +7 -0
- package/types/registry/src/manifest/index.d.ts +9 -0
- package/types/registry/src/manifest/v2.d.ts +182 -0
- package/types/registry/src/semver.d.ts +24 -0
- package/types/registry/src/sort.d.ts +2 -0
- package/types/registry/src/spec.d.ts +19 -0
- package/types/registry/src/text.d.ts +6 -0
- package/types/spatial-nav/src/descent.d.ts +9 -0
- package/types/spatial-nav/src/directions.d.ts +16 -0
- package/types/spatial-nav/src/fallback-focus.d.ts +5 -0
- package/types/spatial-nav/src/focus-owner.d.ts +16 -0
- package/types/spatial-nav/src/focus-tree.d.ts +63 -0
- package/types/spatial-nav/src/index.d.ts +4 -0
- package/types/spatial-nav/src/navigator.bench.d.ts +1 -0
- package/types/spatial-nav/src/react/configure-remote.d.ts +16 -0
- package/types/spatial-nav/src/react/default-focus.d.ts +15 -0
- package/types/spatial-nav/src/react/focus-queue.d.ts +16 -0
- package/types/spatial-nav/src/react/navigator-context.d.ts +19 -0
- package/types/spatial-nav/src/react/navigator-item.d.ts +28 -0
- package/types/spatial-nav/src/react/navigator-node.d.ts +27 -0
- package/types/spatial-nav/src/react/navigator-root.d.ts +19 -0
- package/types/spatial-nav/src/react/navigator-view.d.ts +18 -0
- package/types/spatial-nav/src/react/pointer-device.d.ts +14 -0
- package/types/spatial-nav/src/react/spatial-node.d.ts +27 -0
- package/types/spatial-nav/src/react/use-lock-navigator.d.ts +11 -0
- package/types/spatial-nav/src/react.d.ts +17 -0
- package/types/spatial-nav/src/resolve-move.d.ts +6 -0
- package/types/spatial-nav/src/spatial-navigator.d.ts +23 -0
- package/types/ui/src/assets/fonts.d.ts +4 -0
- package/types/ui/src/components/atoms/art-scrim/art-scrim.d.ts +21 -0
- package/types/ui/src/components/atoms/art-scrim/index.d.ts +1 -0
- package/types/ui/src/components/atoms/avatar/avatar.d.ts +43 -0
- package/types/ui/src/components/atoms/avatar/index.d.ts +1 -0
- package/types/ui/src/components/atoms/badge/badge.d.ts +116 -0
- package/types/ui/src/components/atoms/badge/index.d.ts +1 -0
- package/types/ui/src/components/atoms/box/box.d.ts +29 -0
- package/types/ui/src/components/atoms/box/index.d.ts +1 -0
- package/types/ui/src/components/atoms/button/button-variants.d.ts +216 -0
- package/types/ui/src/components/atoms/button/button.d.ts +37 -0
- package/types/ui/src/components/atoms/button/index.d.ts +1 -0
- package/types/ui/src/components/atoms/checkbox/checkbox.d.ts +62 -0
- package/types/ui/src/components/atoms/checkbox/index.d.ts +1 -0
- package/types/ui/src/components/atoms/chip/chip.d.ts +172 -0
- package/types/ui/src/components/atoms/chip/index.d.ts +1 -0
- package/types/ui/src/components/atoms/divider/divider.d.ts +13 -0
- package/types/ui/src/components/atoms/divider/index.d.ts +1 -0
- package/types/ui/src/components/atoms/expandable-text/expandable-text.d.ts +20 -0
- package/types/ui/src/components/atoms/expandable-text/index.d.ts +1 -0
- package/types/ui/src/components/atoms/focusable/focusable-a11y.d.ts +12 -0
- package/types/ui/src/components/atoms/focusable/focusable-delegate.d.ts +21 -0
- package/types/ui/src/components/atoms/focusable/focusable-forms.d.ts +62 -0
- package/types/ui/src/components/atoms/focusable/focusable-link.d.ts +7 -0
- package/types/ui/src/components/atoms/focusable/focusable-paint.d.ts +47 -0
- package/types/ui/src/components/atoms/focusable/focusable-types.d.ts +167 -0
- package/types/ui/src/components/atoms/focusable/focusable.d.ts +7 -0
- package/types/ui/src/components/atoms/focusable/index.d.ts +1 -0
- package/types/ui/src/components/atoms/focusable/touch-pressable.d.ts +35 -0
- package/types/ui/src/components/atoms/focusable/use-entry-focus.d.ts +9 -0
- package/types/ui/src/components/atoms/focusable/use-web-keys.d.ts +7 -0
- package/types/ui/src/components/atoms/frost/frost.d.ts +62 -0
- package/types/ui/src/components/atoms/frost/index.d.ts +1 -0
- package/types/ui/src/components/atoms/grid/grid.d.ts +28 -0
- package/types/ui/src/components/atoms/grid/index.d.ts +1 -0
- package/types/ui/src/components/atoms/ground/ground.d.ts +19 -0
- package/types/ui/src/components/atoms/ground/index.d.ts +1 -0
- package/types/ui/src/components/atoms/icon/icon.d.ts +4 -0
- package/types/ui/src/components/atoms/icon/index.d.ts +1 -0
- package/types/ui/src/components/atoms/icon-button/icon-button.d.ts +165 -0
- package/types/ui/src/components/atoms/icon-button/index.d.ts +1 -0
- package/types/ui/src/components/atoms/icon-well/icon-well.d.ts +46 -0
- package/types/ui/src/components/atoms/icon-well/index.d.ts +1 -0
- package/types/ui/src/components/atoms/img/img.d.ts +45 -0
- package/types/ui/src/components/atoms/img/index.d.ts +1 -0
- package/types/ui/src/components/atoms/img/native-layers.d.ts +28 -0
- package/types/ui/src/components/atoms/img/use-cross-fade.d.ts +9 -0
- package/types/ui/src/components/atoms/img/web-layers.d.ts +19 -0
- package/types/ui/src/components/atoms/index.d.ts +64 -0
- package/types/ui/src/components/atoms/kbd/index.d.ts +2 -0
- package/types/ui/src/components/atoms/kbd/kbd.d.ts +18 -0
- package/types/ui/src/components/atoms/logo/index.d.ts +1 -0
- package/types/ui/src/components/atoms/logo/logo.d.ts +11 -0
- package/types/ui/src/components/atoms/number-field/index.d.ts +1 -0
- package/types/ui/src/components/atoms/number-field/number-field.d.ts +11 -0
- package/types/ui/src/components/atoms/progress/index.d.ts +1 -0
- package/types/ui/src/components/atoms/progress/progress.d.ts +28 -0
- package/types/ui/src/components/atoms/progress-ring/index.d.ts +1 -0
- package/types/ui/src/components/atoms/progress-ring/progress-ring.d.ts +7 -0
- package/types/ui/src/components/atoms/radio/index.d.ts +1 -0
- package/types/ui/src/components/atoms/radio/radio.d.ts +76 -0
- package/types/ui/src/components/atoms/skeleton/card-skeleton.d.ts +6 -0
- package/types/ui/src/components/atoms/skeleton/index.d.ts +4 -0
- package/types/ui/src/components/atoms/skeleton/poster-skeleton.d.ts +7 -0
- package/types/ui/src/components/atoms/skeleton/skeleton.d.ts +20 -0
- package/types/ui/src/components/atoms/skeleton/table-skeleton.d.ts +6 -0
- package/types/ui/src/components/atoms/spinner/index.d.ts +1 -0
- package/types/ui/src/components/atoms/spinner/spinner.d.ts +14 -0
- package/types/ui/src/components/atoms/status-dot/index.d.ts +1 -0
- package/types/ui/src/components/atoms/status-dot/status-dot.d.ts +9 -0
- package/types/ui/src/components/atoms/surface/index.d.ts +1 -0
- package/types/ui/src/components/atoms/surface/surface.d.ts +56 -0
- package/types/ui/src/components/atoms/switch/index.d.ts +1 -0
- package/types/ui/src/components/atoms/switch/switch.d.ts +64 -0
- package/types/ui/src/components/atoms/text/index.d.ts +1 -0
- package/types/ui/src/components/atoms/text/text.d.ts +21 -0
- package/types/ui/src/components/atoms/text-area/index.d.ts +1 -0
- package/types/ui/src/components/atoms/text-area/text-area.d.ts +31 -0
- package/types/ui/src/components/atoms/text-field/index.d.ts +1 -0
- package/types/ui/src/components/atoms/text-field/text-field.d.ts +50 -0
- package/types/ui/src/components/atoms/watched-badge/index.d.ts +1 -0
- package/types/ui/src/components/atoms/watched-badge/watched-badge.d.ts +19 -0
- package/types/ui/src/components/atoms/wheel/index.d.ts +1 -0
- package/types/ui/src/components/atoms/wheel/wheel.d.ts +9 -0
- package/types/ui/src/components/common/if/if.d.ts +9 -0
- package/types/ui/src/components/common/if/index.d.ts +1 -0
- package/types/ui/src/components/common/index.d.ts +2 -0
- package/types/ui/src/components/molecules/add-tile/add-tile.d.ts +65 -0
- package/types/ui/src/components/molecules/add-tile/index.d.ts +2 -0
- package/types/ui/src/components/molecules/alphabet-rail/alphabet-rail-context.d.ts +20 -0
- package/types/ui/src/components/molecules/alphabet-rail/alphabet-rail-item.d.ts +13 -0
- package/types/ui/src/components/molecules/alphabet-rail/alphabet-rail-lens.d.ts +17 -0
- package/types/ui/src/components/molecules/alphabet-rail/alphabet-rail.d.ts +46 -0
- package/types/ui/src/components/molecules/alphabet-rail/index.d.ts +2 -0
- package/types/ui/src/components/molecules/alphabet-rail/use-letter-scrub.d.ts +17 -0
- package/types/ui/src/components/molecules/back-button/back-button.d.ts +10 -0
- package/types/ui/src/components/molecules/back-button/index.d.ts +1 -0
- package/types/ui/src/components/molecules/button-group/button-group.d.ts +37 -0
- package/types/ui/src/components/molecules/button-group/index.d.ts +3 -0
- package/types/ui/src/components/molecules/callout/callout.d.ts +63 -0
- package/types/ui/src/components/molecules/callout/index.d.ts +1 -0
- package/types/ui/src/components/molecules/category-tile/category-tile.d.ts +65 -0
- package/types/ui/src/components/molecules/category-tile/index.d.ts +1 -0
- package/types/ui/src/components/molecules/choice-list/choice-list.d.ts +53 -0
- package/types/ui/src/components/molecules/choice-list/index.d.ts +1 -0
- package/types/ui/src/components/molecules/copy-button/copy-button.d.ts +19 -0
- package/types/ui/src/components/molecules/copy-button/index.d.ts +1 -0
- package/types/ui/src/components/molecules/data-field/data-field.d.ts +44 -0
- package/types/ui/src/components/molecules/data-field/index.d.ts +1 -0
- package/types/ui/src/components/molecules/disclosure/disclosure.d.ts +55 -0
- package/types/ui/src/components/molecules/disclosure/index.d.ts +1 -0
- package/types/ui/src/components/molecules/dropzone/dropzone-parts.d.ts +46 -0
- package/types/ui/src/components/molecules/dropzone/dropzone-sift.d.ts +6 -0
- package/types/ui/src/components/molecules/dropzone/dropzone.d.ts +21 -0
- package/types/ui/src/components/molecules/dropzone/dropzone.web.d.ts +11 -0
- package/types/ui/src/components/molecules/dropzone/index.d.ts +1 -0
- package/types/ui/src/components/molecules/empty-state/empty-state.d.ts +60 -0
- package/types/ui/src/components/molecules/empty-state/index.d.ts +1 -0
- package/types/ui/src/components/molecules/field/field.d.ts +56 -0
- package/types/ui/src/components/molecules/field/index.d.ts +1 -0
- package/types/ui/src/components/molecules/hint/hint.d.ts +23 -0
- package/types/ui/src/components/molecules/hint/index.d.ts +1 -0
- package/types/ui/src/components/molecules/index.d.ts +70 -0
- package/types/ui/src/components/molecules/input-group/index.d.ts +3 -0
- package/types/ui/src/components/molecules/input-group/input-group-context.d.ts +34 -0
- package/types/ui/src/components/molecules/input-group/input-group-parts.d.ts +31 -0
- package/types/ui/src/components/molecules/input-group/input-group.d.ts +38 -0
- package/types/ui/src/components/molecules/keypad/index.d.ts +1 -0
- package/types/ui/src/components/molecules/keypad/keypad.d.ts +44 -0
- package/types/ui/src/components/molecules/legend/index.d.ts +1 -0
- package/types/ui/src/components/molecules/legend/legend.d.ts +32 -0
- package/types/ui/src/components/molecules/list/index.d.ts +1 -0
- package/types/ui/src/components/molecules/list/list.d.ts +41 -0
- package/types/ui/src/components/molecules/list-row/index.d.ts +3 -0
- package/types/ui/src/components/molecules/list-row/list-group.d.ts +23 -0
- package/types/ui/src/components/molecules/list-row/list-row-context.d.ts +10 -0
- package/types/ui/src/components/molecules/list-row/list-row-parts.d.ts +28 -0
- package/types/ui/src/components/molecules/list-row/list-row-variants.d.ts +90 -0
- package/types/ui/src/components/molecules/list-row/list-row.d.ts +51 -0
- package/types/ui/src/components/molecules/media-card/index.d.ts +1 -0
- package/types/ui/src/components/molecules/media-card/media-card.d.ts +22 -0
- package/types/ui/src/components/molecules/nav-pill/index.d.ts +1 -0
- package/types/ui/src/components/molecules/nav-pill/nav-pill-context.d.ts +28 -0
- package/types/ui/src/components/molecules/nav-pill/nav-pill-item.d.ts +101 -0
- package/types/ui/src/components/molecules/nav-pill/nav-pill-lens.d.ts +8 -0
- package/types/ui/src/components/molecules/nav-pill/nav-pill.d.ts +55 -0
- package/types/ui/src/components/molecules/otp-field/index.d.ts +1 -0
- package/types/ui/src/components/molecules/otp-field/otp-field-context.d.ts +32 -0
- package/types/ui/src/components/molecules/otp-field/otp-field-parts.d.ts +18 -0
- package/types/ui/src/components/molecules/otp-field/otp-field-variants.d.ts +68 -0
- package/types/ui/src/components/molecules/otp-field/otp-field.d.ts +57 -0
- package/types/ui/src/components/molecules/page-header/index.d.ts +1 -0
- package/types/ui/src/components/molecules/page-header/page-header.d.ts +69 -0
- package/types/ui/src/components/molecules/pagination/index.d.ts +3 -0
- package/types/ui/src/components/molecules/pagination/pagination.d.ts +102 -0
- package/types/ui/src/components/molecules/pagination/paging.d.ts +24 -0
- package/types/ui/src/components/molecules/person-card/index.d.ts +1 -0
- package/types/ui/src/components/molecules/person-card/person-card.d.ts +58 -0
- package/types/ui/src/components/molecules/pin-field/index.d.ts +1 -0
- package/types/ui/src/components/molecules/pin-field/pin-field.d.ts +26 -0
- package/types/ui/src/components/molecules/poster-card/index.d.ts +1 -0
- package/types/ui/src/components/molecules/poster-card/poster-card.d.ts +22 -0
- package/types/ui/src/components/molecules/section/index.d.ts +1 -0
- package/types/ui/src/components/molecules/section/section.d.ts +54 -0
- package/types/ui/src/components/molecules/segment-group/index.d.ts +2 -0
- package/types/ui/src/components/molecules/segment-group/segment-group-context.d.ts +17 -0
- package/types/ui/src/components/molecules/segment-group/segment-group-item.d.ts +58 -0
- package/types/ui/src/components/molecules/segment-group/segment-group.d.ts +29 -0
- package/types/ui/src/components/molecules/select/index.d.ts +1 -0
- package/types/ui/src/components/molecules/select/select-context.d.ts +54 -0
- package/types/ui/src/components/molecules/select/select-item.d.ts +39 -0
- package/types/ui/src/components/molecules/select/select-options-dialog.d.ts +3 -0
- package/types/ui/src/components/molecules/select/select-options.d.ts +3 -0
- package/types/ui/src/components/molecules/select/select-selection.d.ts +24 -0
- package/types/ui/src/components/molecules/select/select-surface.d.ts +17 -0
- package/types/ui/src/components/molecules/select/select.d.ts +112 -0
- package/types/ui/src/components/molecules/stat-card/index.d.ts +1 -0
- package/types/ui/src/components/molecules/stat-card/stat-card.d.ts +46 -0
- package/types/ui/src/components/molecules/stepper/index.d.ts +1 -0
- package/types/ui/src/components/molecules/stepper/stepper-context.d.ts +44 -0
- package/types/ui/src/components/molecules/stepper/stepper-item.d.ts +110 -0
- package/types/ui/src/components/molecules/stepper/stepper-list.d.ts +12 -0
- package/types/ui/src/components/molecules/stepper/stepper.d.ts +97 -0
- package/types/ui/src/components/molecules/stepper/use-steps.d.ts +40 -0
- package/types/ui/src/components/molecules/theme-switch/index.d.ts +1 -0
- package/types/ui/src/components/molecules/theme-switch/theme-switch.d.ts +19 -0
- package/types/ui/src/components/molecules/timeline/index.d.ts +1 -0
- package/types/ui/src/components/molecules/timeline/timeline.d.ts +55 -0
- package/types/ui/src/components/molecules/tooltip/index.d.ts +1 -0
- package/types/ui/src/components/molecules/tooltip/tooltip.d.ts +9 -0
- package/types/ui/src/components/molecules/tooltip/tooltip.web.d.ts +4 -0
- package/types/ui/src/components/organisms/chart/chart-context.d.ts +38 -0
- package/types/ui/src/components/organisms/chart/chart-marks.d.ts +32 -0
- package/types/ui/src/components/organisms/chart/chart-parts.d.ts +41 -0
- package/types/ui/src/components/organisms/chart/chart-path.d.ts +28 -0
- package/types/ui/src/components/organisms/chart/chart-scale.d.ts +82 -0
- package/types/ui/src/components/organisms/chart/chart.d.ts +63 -0
- package/types/ui/src/components/organisms/chart/index.d.ts +5 -0
- package/types/ui/src/components/organisms/code-block/code-block.d.ts +23 -0
- package/types/ui/src/components/organisms/code-block/code-tokens.d.ts +15 -0
- package/types/ui/src/components/organisms/code-block/index.d.ts +1 -0
- package/types/ui/src/components/organisms/command/command-context.d.ts +31 -0
- package/types/ui/src/components/organisms/command/command-keys-types.d.ts +11 -0
- package/types/ui/src/components/organisms/command/command-keys.d.ts +3 -0
- package/types/ui/src/components/organisms/command/command-keys.web.d.ts +3 -0
- package/types/ui/src/components/organisms/command/command-list.d.ts +46 -0
- package/types/ui/src/components/organisms/command/command-parts.d.ts +24 -0
- package/types/ui/src/components/organisms/command/command-row.d.ts +15 -0
- package/types/ui/src/components/organisms/command/command.d.ts +45 -0
- package/types/ui/src/components/organisms/command/index.d.ts +7 -0
- package/types/ui/src/components/organisms/dialog/confirm-dialog/confirm-dialog.d.ts +12 -0
- package/types/ui/src/components/organisms/dialog/confirm-dialog/confirm.d.ts +16 -0
- package/types/ui/src/components/organisms/dialog/confirm-dialog/index.d.ts +2 -0
- package/types/ui/src/components/organisms/dialog/dialog-actions.d.ts +29 -0
- package/types/ui/src/components/organisms/dialog/dialog-parts.d.ts +20 -0
- package/types/ui/src/components/organisms/dialog/dialog.d.ts +55 -0
- package/types/ui/src/components/organisms/dialog/index.d.ts +3 -0
- package/types/ui/src/components/organisms/drawer/drawer-parts.d.ts +29 -0
- package/types/ui/src/components/organisms/drawer/drawer-slide.d.ts +20 -0
- package/types/ui/src/components/organisms/drawer/drawer.d.ts +64 -0
- package/types/ui/src/components/organisms/drawer/index.d.ts +2 -0
- package/types/ui/src/components/organisms/index.d.ts +31 -0
- package/types/ui/src/components/organisms/keyboard/index.d.ts +8 -0
- package/types/ui/src/components/organisms/keyboard/key.d.ts +57 -0
- package/types/ui/src/components/organisms/keyboard/keyboard-layouts.d.ts +27 -0
- package/types/ui/src/components/organisms/keyboard/search-keyboard/index.d.ts +1 -0
- package/types/ui/src/components/organisms/keyboard/search-keyboard/search-keyboard.d.ts +19 -0
- package/types/ui/src/components/organisms/keyboard/url-keyboard/index.d.ts +1 -0
- package/types/ui/src/components/organisms/keyboard/url-keyboard/url-keyboard.d.ts +20 -0
- package/types/ui/src/components/organisms/keyboard/use-physical-typing.d.ts +2 -0
- package/types/ui/src/components/organisms/kroma-intro/animations.d.ts +2 -0
- package/types/ui/src/components/organisms/kroma-intro/constants.d.ts +14 -0
- package/types/ui/src/components/organisms/kroma-intro/css-intro.d.ts +12 -0
- package/types/ui/src/components/organisms/kroma-intro/index.d.ts +3 -0
- package/types/ui/src/components/organisms/kroma-intro/intro-scene.d.ts +21 -0
- package/types/ui/src/components/organisms/kroma-intro/intro-shell.d.ts +10 -0
- package/types/ui/src/components/organisms/kroma-intro/kroma-intro.d.ts +3 -0
- package/types/ui/src/components/organisms/kroma-intro/kroma-intro.web.d.ts +33 -0
- package/types/ui/src/components/organisms/kroma-intro/use-intro-exit.d.ts +21 -0
- package/types/ui/src/components/organisms/kroma-intro/use-intro-keys.d.ts +19 -0
- package/types/ui/src/components/organisms/menu/index.d.ts +1 -0
- package/types/ui/src/components/organisms/menu/menu-context.d.ts +32 -0
- package/types/ui/src/components/organisms/menu/menu-item.d.ts +57 -0
- package/types/ui/src/components/organisms/menu/menu-surface-dialog.d.ts +25 -0
- package/types/ui/src/components/organisms/menu/menu-surface.d.ts +3 -0
- package/types/ui/src/components/organisms/menu/menu.d.ts +49 -0
- package/types/ui/src/components/organisms/nearby-tv-list/index.d.ts +2 -0
- package/types/ui/src/components/organisms/nearby-tv-list/nearby-tv-list.d.ts +12 -0
- package/types/ui/src/components/organisms/perf-hud/index.d.ts +1 -0
- package/types/ui/src/components/organisms/perf-hud/perf-chart.d.ts +5 -0
- package/types/ui/src/components/organisms/perf-hud/perf-hud.d.ts +4 -0
- package/types/ui/src/components/organisms/player/hooks/use-drag-track.d.ts +22 -0
- package/types/ui/src/components/organisms/player/hooks/use-grid-focus.d.ts +19 -0
- package/types/ui/src/components/organisms/player/hooks/use-idle-cursor.d.ts +7 -0
- package/types/ui/src/components/organisms/player/hooks/use-list-focus.d.ts +40 -0
- package/types/ui/src/components/organisms/player/hooks/use-player-credits.d.ts +22 -0
- package/types/ui/src/components/organisms/player/hooks/use-player-ending.d.ts +37 -0
- package/types/ui/src/components/organisms/player/hooks/use-player-keys.d.ts +8 -0
- package/types/ui/src/components/organisms/player/hooks/use-player-keys.web.d.ts +5 -0
- package/types/ui/src/components/organisms/player/hooks/use-player-nav.d.ts +58 -0
- package/types/ui/src/components/organisms/player/hooks/use-player-outro.d.ts +14 -0
- package/types/ui/src/components/organisms/player/hooks/use-seek-nudge.d.ts +8 -0
- package/types/ui/src/components/organisms/player/index.d.ts +22 -0
- package/types/ui/src/components/organisms/player/lib/audio-filter.d.ts +15 -0
- package/types/ui/src/components/organisms/player/lib/chapters.d.ts +16 -0
- package/types/ui/src/components/organisms/player/lib/chart-geometry.d.ts +46 -0
- package/types/ui/src/components/organisms/player/lib/fmt.d.ts +19 -0
- package/types/ui/src/components/organisms/player/lib/lean-stats.d.ts +34 -0
- package/types/ui/src/components/organisms/player/lib/metrics.d.ts +40 -0
- package/types/ui/src/components/organisms/player/lib/nav-keys.d.ts +19 -0
- package/types/ui/src/components/organisms/player/lib/nav.d.ts +38 -0
- package/types/ui/src/components/organisms/player/lib/panel-header.d.ts +12 -0
- package/types/ui/src/components/organisms/player/lib/panel-slide.d.ts +16 -0
- package/types/ui/src/components/organisms/player/lib/player-keys.d.ts +44 -0
- package/types/ui/src/components/organisms/player/lib/seek-track.d.ts +19 -0
- package/types/ui/src/components/organisms/player/lib/stage-card.d.ts +31 -0
- package/types/ui/src/components/organisms/player/lib/stage-ratio.d.ts +4 -0
- package/types/ui/src/components/organisms/player/lib/stage-ratio.web.d.ts +2 -0
- package/types/ui/src/components/organisms/player/lib/style.d.ts +40 -0
- package/types/ui/src/components/organisms/player/lib/styles.d.ts +3 -0
- package/types/ui/src/components/organisms/player/lib/subtitle-appearance.d.ts +53 -0
- package/types/ui/src/components/organisms/player/lib/subtitle-edge.d.ts +3 -0
- package/types/ui/src/components/organisms/player/lib/subtitle-edge.web.d.ts +3 -0
- package/types/ui/src/components/organisms/player/lib/surface-shrink.d.ts +17 -0
- package/types/ui/src/components/organisms/player/lib/virtual-focus.d.ts +2 -0
- package/types/ui/src/components/organisms/player/lib/virtual-focus.web.d.ts +3 -0
- package/types/ui/src/components/organisms/player/parts/control-cluster/control-cluster.d.ts +32 -0
- package/types/ui/src/components/organisms/player/parts/control-cluster/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/credits-card/credits-card.d.ts +25 -0
- package/types/ui/src/components/organisms/player/parts/credits-card/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/icons.d.ts +39 -0
- package/types/ui/src/components/organisms/player/parts/post-play/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/post-play/post-play.d.ts +41 -0
- package/types/ui/src/components/organisms/player/parts/post-play/rise.d.ts +12 -0
- package/types/ui/src/components/organisms/player/parts/post-play/rise.web.d.ts +10 -0
- package/types/ui/src/components/organisms/player/parts/seek-bar/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/seek-bar/seek-bar.d.ts +22 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/audio-filter-panel.d.ts +11 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/audio-panel.d.ts +11 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/entries.d.ts +35 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/gen.d.ts +24 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/generate-wizard.d.ts +18 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/menu-list.d.ts +9 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/menu-row.d.ts +15 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/panel-style.d.ts +99 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/quality-panel.d.ts +16 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/report-panel.d.ts +8 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/select-row.d.ts +21 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/speed-panel.d.ts +10 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/sub-view.d.ts +16 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/subtitle-appearance-panel.d.ts +14 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/subtitle-appearance-parts.d.ts +27 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/subtitles-panel.d.ts +18 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/title-bar.d.ts +9 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings/wizard-parts.d.ts +8 -0
- package/types/ui/src/components/organisms/player/parts/settings-panel/settings-panel.d.ts +40 -0
- package/types/ui/src/components/organisms/player/parts/skip-intro-button/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/skip-intro-button/skip-intro-button.d.ts +22 -0
- package/types/ui/src/components/organisms/player/parts/stage/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/stage/stage-overlay.d.ts +13 -0
- package/types/ui/src/components/organisms/player/parts/stage/stage.d.ts +30 -0
- package/types/ui/src/components/organisms/player/parts/stats-panel/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/stats-panel/stats-chart.d.ts +16 -0
- package/types/ui/src/components/organisms/player/parts/stats-panel/stats-panel.d.ts +14 -0
- package/types/ui/src/components/organisms/player/parts/storyboard-thumb/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/storyboard-thumb/storyboard-thumb.d.ts +4 -0
- package/types/ui/src/components/organisms/player/parts/subtitle-renderer/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/subtitle-renderer/subtitle-renderer.d.ts +32 -0
- package/types/ui/src/components/organisms/player/parts/surface-radius.d.ts +9 -0
- package/types/ui/src/components/organisms/player/parts/top-bar/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/top-bar/top-bar.d.ts +24 -0
- package/types/ui/src/components/organisms/player/parts/transport/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/transport/transport.d.ts +19 -0
- package/types/ui/src/components/organisms/player/parts/up-next-card/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/up-next-card/up-next-card.d.ts +37 -0
- package/types/ui/src/components/organisms/player/parts/up-next-sheet/index.d.ts +1 -0
- package/types/ui/src/components/organisms/player/parts/up-next-sheet/slide.d.ts +5 -0
- package/types/ui/src/components/organisms/player/parts/up-next-sheet/slide.web.d.ts +5 -0
- package/types/ui/src/components/organisms/player/parts/up-next-sheet/up-next-sheet.d.ts +17 -0
- package/types/ui/src/components/organisms/player/player-chrome-state.d.ts +11 -0
- package/types/ui/src/components/organisms/player/player-input.d.ts +16 -0
- package/types/ui/src/components/organisms/player/player-parts.d.ts +34 -0
- package/types/ui/src/components/organisms/player/player.d.ts +63 -0
- package/types/ui/src/components/organisms/player/types.d.ts +226 -0
- package/types/ui/src/components/organisms/rail/index.d.ts +1 -0
- package/types/ui/src/components/organisms/rail/rail-context.d.ts +7 -0
- package/types/ui/src/components/organisms/rail/rail-row.d.ts +22 -0
- package/types/ui/src/components/organisms/rail/rail.d.ts +63 -0
- package/types/ui/src/components/organisms/resizable/index.d.ts +8 -0
- package/types/ui/src/components/organisms/resizable/resizable-context.d.ts +39 -0
- package/types/ui/src/components/organisms/resizable/resizable-cursor.d.ts +3 -0
- package/types/ui/src/components/organisms/resizable/resizable-cursor.web.d.ts +4 -0
- package/types/ui/src/components/organisms/resizable/resizable-handle.d.ts +30 -0
- package/types/ui/src/components/organisms/resizable/resizable-keys-types.d.ts +11 -0
- package/types/ui/src/components/organisms/resizable/resizable-keys.d.ts +3 -0
- package/types/ui/src/components/organisms/resizable/resizable-keys.web.d.ts +3 -0
- package/types/ui/src/components/organisms/resizable/resizable-layout.d.ts +55 -0
- package/types/ui/src/components/organisms/resizable/resizable-panel.d.ts +55 -0
- package/types/ui/src/components/organisms/resizable/resizable-store.d.ts +18 -0
- package/types/ui/src/components/organisms/resizable/resizable.d.ts +59 -0
- package/types/ui/src/components/organisms/splash-backdrop/index.d.ts +2 -0
- package/types/ui/src/components/organisms/splash-backdrop/splash-backdrop.d.ts +22 -0
- package/types/ui/src/components/organisms/table/index.d.ts +1 -0
- package/types/ui/src/components/organisms/table/table-cell.d.ts +9 -0
- package/types/ui/src/components/organisms/table/table-columns.d.ts +32 -0
- package/types/ui/src/components/organisms/table/table-context.d.ts +17 -0
- package/types/ui/src/components/organisms/table/table-frame.d.ts +9 -0
- package/types/ui/src/components/organisms/table/table-place.d.ts +8 -0
- package/types/ui/src/components/organisms/table/table-row.d.ts +12 -0
- package/types/ui/src/components/organisms/table/table-sort-cell.d.ts +14 -0
- package/types/ui/src/components/organisms/table/table-sort.d.ts +38 -0
- package/types/ui/src/components/organisms/table/table.d.ts +65 -0
- package/types/ui/src/components/organisms/toast/index.d.ts +1 -0
- package/types/ui/src/components/organisms/toast/toast-card.d.ts +8 -0
- package/types/ui/src/components/organisms/toast/toast.d.ts +54 -0
- package/types/ui/src/components/organisms/virtual/clip.d.ts +25 -0
- package/types/ui/src/components/organisms/virtual/index.d.ts +2 -0
- package/types/ui/src/components/organisms/virtual/moving-strip.d.ts +16 -0
- package/types/ui/src/components/organisms/virtual/strip-motion.d.ts +4 -0
- package/types/ui/src/components/organisms/virtual/virtual-grid/grid-row.d.ts +25 -0
- package/types/ui/src/components/organisms/virtual/virtual-grid/grid-rows.d.ts +57 -0
- package/types/ui/src/components/organisms/virtual/virtual-grid/index.d.ts +1 -0
- package/types/ui/src/components/organisms/virtual/virtual-grid/use-wheel-rows.d.ts +8 -0
- package/types/ui/src/components/organisms/virtual/virtual-grid/virtual-grid.d.ts +54 -0
- package/types/ui/src/components/organisms/virtual/virtual-rail/edge-scroll.d.ts +38 -0
- package/types/ui/src/components/organisms/virtual/virtual-rail/index.d.ts +1 -0
- package/types/ui/src/components/organisms/virtual/virtual-rail/rail-edge.d.ts +11 -0
- package/types/ui/src/components/organisms/virtual/virtual-rail/use-key-grace.d.ts +6 -0
- package/types/ui/src/components/organisms/virtual/virtual-rail/virtual-rail.d.ts +19 -0
- package/types/ui/src/components/templates/index.d.ts +2 -0
- package/types/ui/src/components/templates/tv-stage/index.d.ts +1 -0
- package/types/ui/src/components/templates/tv-stage/tv-stage.d.ts +7 -0
- package/types/ui/src/core/atomic/index.d.ts +5 -0
- package/types/ui/src/core/atomic/inject.d.ts +3 -0
- package/types/ui/src/core/atomic/register.d.ts +13 -0
- package/types/ui/src/core/atomic/static-style.d.ts +8 -0
- package/types/ui/src/core/breakpoint-cascade.d.ts +45 -0
- package/types/ui/src/core/breakpoint.d.ts +21 -0
- package/types/ui/src/core/color.d.ts +21 -0
- package/types/ui/src/core/index.d.ts +20 -0
- package/types/ui/src/core/normalize.d.ts +21 -0
- package/types/ui/src/core/recipe.d.ts +21 -0
- package/types/ui/src/core/shorthand-resolve.d.ts +54 -0
- package/types/ui/src/core/shorthands.d.ts +187 -0
- package/types/ui/src/core/stabilise.d.ts +14 -0
- package/types/ui/src/core/states.d.ts +16 -0
- package/types/ui/src/core/styles.d.ts +59 -0
- package/types/ui/src/core/theme-create.d.ts +64 -0
- package/types/ui/src/core/theme-mode.d.ts +15 -0
- package/types/ui/src/core/theme.d.ts +72 -0
- package/types/ui/src/core/tokens/colors.d.ts +109 -0
- package/types/ui/src/core/tokens/css-palette.d.ts +19 -0
- package/types/ui/src/core/tokens/css-var.d.ts +8 -0
- package/types/ui/src/core/tokens/effects.d.ts +103 -0
- package/types/ui/src/core/tokens/index.d.ts +10 -0
- package/types/ui/src/core/tokens/layout.d.ts +94 -0
- package/types/ui/src/core/tokens/mobile.d.ts +91 -0
- package/types/ui/src/core/tokens/registry.d.ts +4 -0
- package/types/ui/src/core/tokens/typography.d.ts +232 -0
- package/types/ui/src/core/types.d.ts +122 -0
- package/types/ui/src/core/use-breakpoint.d.ts +16 -0
- package/types/ui/src/core/use-theme.d.ts +30 -0
- package/types/ui/src/core/web-style.d.ts +91 -0
- package/types/ui/src/index.d.ts +20 -0
- package/types/ui/src/kit.d.ts +74 -0
- package/types/ui/src/lib/a11y-props.d.ts +26 -0
- package/types/ui/src/lib/a11y.d.ts +8 -0
- package/types/ui/src/lib/anchor.d.ts +32 -0
- package/types/ui/src/lib/anchored-keys.d.ts +41 -0
- package/types/ui/src/lib/anchored-panel.d.ts +42 -0
- package/types/ui/src/lib/anchored-popup.d.ts +17 -0
- package/types/ui/src/lib/box-layers.d.ts +10 -0
- package/types/ui/src/lib/box-style.d.ts +16 -0
- package/types/ui/src/lib/caret.d.ts +8 -0
- package/types/ui/src/lib/classed.d.ts +3 -0
- package/types/ui/src/lib/cover-rect.d.ts +26 -0
- package/types/ui/src/lib/css.d.ts +19 -0
- package/types/ui/src/lib/css.web.d.ts +25 -0
- package/types/ui/src/lib/cursor.d.ts +17 -0
- package/types/ui/src/lib/dismiss-backdrop.d.ts +11 -0
- package/types/ui/src/lib/dom.d.ts +12 -0
- package/types/ui/src/lib/drag-select.d.ts +1 -0
- package/types/ui/src/lib/drag-select.web.d.ts +13 -0
- package/types/ui/src/lib/ease.d.ts +13 -0
- package/types/ui/src/lib/escape-guard.d.ts +1 -0
- package/types/ui/src/lib/expo-image-backend.d.ts +5 -0
- package/types/ui/src/lib/field-shell.d.ts +140 -0
- package/types/ui/src/lib/focus-entry.d.ts +20 -0
- package/types/ui/src/lib/focus-here.d.ts +11 -0
- package/types/ui/src/lib/focus-here.web.d.ts +7 -0
- package/types/ui/src/lib/focus-lift.d.ts +39 -0
- package/types/ui/src/lib/focus-nav.d.ts +3 -0
- package/types/ui/src/lib/focus-nav.web.d.ts +2 -0
- package/types/ui/src/lib/focus-platform.d.ts +30 -0
- package/types/ui/src/lib/focus-presence.d.ts +5 -0
- package/types/ui/src/lib/focus-remote.d.ts +39 -0
- package/types/ui/src/lib/focus-remote.web.d.ts +16 -0
- package/types/ui/src/lib/focus-report.d.ts +18 -0
- package/types/ui/src/lib/focus-root.d.ts +22 -0
- package/types/ui/src/lib/focus-root.web.d.ts +3 -0
- package/types/ui/src/lib/focus-scope.d.ts +59 -0
- package/types/ui/src/lib/focus-scroll.d.ts +69 -0
- package/types/ui/src/lib/focus-tab.d.ts +12 -0
- package/types/ui/src/lib/focus-transition.d.ts +11 -0
- package/types/ui/src/lib/focus-transition.web.d.ts +3 -0
- package/types/ui/src/lib/focus-types.d.ts +18 -0
- package/types/ui/src/lib/focus-visible.d.ts +21 -0
- package/types/ui/src/lib/form/index.d.ts +4 -0
- package/types/ui/src/lib/form/message.d.ts +10 -0
- package/types/ui/src/lib/form/standard-schema.d.ts +27 -0
- package/types/ui/src/lib/form/use-form.d.ts +59 -0
- package/types/ui/src/lib/fuzzy-search.d.ts +20 -0
- package/types/ui/src/lib/genre-icon.d.ts +4 -0
- package/types/ui/src/lib/glyph.d.ts +24 -0
- package/types/ui/src/lib/group-shape.d.ts +44 -0
- package/types/ui/src/lib/hover-passthrough.d.ts +9 -0
- package/types/ui/src/lib/icon-catalog.d.ts +19 -0
- package/types/ui/src/lib/icon-search.d.ts +18 -0
- package/types/ui/src/lib/icons/every-glyph.d.ts +4 -0
- package/types/ui/src/lib/icons/every-glyph.web.d.ts +4 -0
- package/types/ui/src/lib/icons/glyph-source.d.ts +3 -0
- package/types/ui/src/lib/icons/glyphs.d.ts +34 -0
- package/types/ui/src/lib/icons/library.d.ts +19 -0
- package/types/ui/src/lib/icons/stroke-prop.d.ts +2 -0
- package/types/ui/src/lib/icons/stroke-prop.web.d.ts +2 -0
- package/types/ui/src/lib/image-backend.d.ts +26 -0
- package/types/ui/src/lib/input-gate.d.ts +11 -0
- package/types/ui/src/lib/input-source.d.ts +3 -0
- package/types/ui/src/lib/landmark.d.ts +4 -0
- package/types/ui/src/lib/landmark.web.d.ts +4 -0
- package/types/ui/src/lib/lockup-paths.d.ts +10 -0
- package/types/ui/src/lib/loop.d.ts +15 -0
- package/types/ui/src/lib/loop.web.d.ts +5 -0
- package/types/ui/src/lib/modal-portal.d.ts +3 -0
- package/types/ui/src/lib/modal-portal.web.d.ts +8 -0
- package/types/ui/src/lib/name-of.d.ts +9 -0
- package/types/ui/src/lib/nav-style.d.ts +5 -0
- package/types/ui/src/lib/overlay-host.d.ts +23 -0
- package/types/ui/src/lib/part-context.d.ts +8 -0
- package/types/ui/src/lib/perf-memory.d.ts +12 -0
- package/types/ui/src/lib/perf-memory.web.d.ts +4 -0
- package/types/ui/src/lib/perf.d.ts +35 -0
- package/types/ui/src/lib/platform.d.ts +3 -0
- package/types/ui/src/lib/platform.web.d.ts +2 -0
- package/types/ui/src/lib/portal.d.ts +10 -0
- package/types/ui/src/lib/portal.web.d.ts +17 -0
- package/types/ui/src/lib/press-dip.d.ts +26 -0
- package/types/ui/src/lib/press-guard.d.ts +8 -0
- package/types/ui/src/lib/progress-motion.d.ts +11 -0
- package/types/ui/src/lib/progress-motion.web.d.ts +11 -0
- package/types/ui/src/lib/reduced-motion.d.ts +7 -0
- package/types/ui/src/lib/report-categories.d.ts +10 -0
- package/types/ui/src/lib/ring-room.d.ts +27 -0
- package/types/ui/src/lib/ring-scope.d.ts +6 -0
- package/types/ui/src/lib/ring.d.ts +27 -0
- package/types/ui/src/lib/sample-art.d.ts +9 -0
- package/types/ui/src/lib/scroll-lock.d.ts +1 -0
- package/types/ui/src/lib/scroll-lock.web.d.ts +6 -0
- package/types/ui/src/lib/shake.d.ts +8 -0
- package/types/ui/src/lib/shake.web.d.ts +4 -0
- package/types/ui/src/lib/slot.d.ts +36 -0
- package/types/ui/src/lib/sort-icon.d.ts +5 -0
- package/types/ui/src/lib/splash-motion.d.ts +25 -0
- package/types/ui/src/lib/splash-motion.web.d.ts +15 -0
- package/types/ui/src/lib/stable-callback.d.ts +9 -0
- package/types/ui/src/lib/surface-bands.d.ts +26 -0
- package/types/ui/src/lib/surface-presentation.d.ts +17 -0
- package/types/ui/src/lib/surface-shell.d.ts +21 -0
- package/types/ui/src/lib/svg.d.ts +1 -0
- package/types/ui/src/lib/svg.web.d.ts +17 -0
- package/types/ui/src/lib/theme-audio.d.ts +7 -0
- package/types/ui/src/lib/tv-remote.d.ts +11 -0
- package/types/ui/src/lib/use-complete-once.d.ts +12 -0
- package/types/ui/src/lib/use-controllable.d.ts +1 -0
- package/types/ui/src/lib/use-copy.d.ts +20 -0
- package/types/ui/src/lib/use-growing-count.d.ts +12 -0
- package/types/ui/src/lib/use-settled-value.d.ts +5 -0
- package/types/ui/src/lib/wheel-pan.d.ts +7 -0
- package/types/ui/src/lib/wheel-pan.web.d.ts +11 -0
- package/types/ui/src/lib/wheel-paths.d.ts +5 -0
- package/types/ui/src/services/aiSuggest.d.ts +15 -0
- package/types/ui/src/services/auth.d.ts +41 -0
- package/types/ui/src/services/cast-context.d.ts +33 -0
- package/types/ui/src/services/cast-events.d.ts +23 -0
- package/types/ui/src/services/cast-lan.d.ts +21 -0
- package/types/ui/src/services/cast-position.d.ts +14 -0
- package/types/ui/src/services/cast.d.ts +20 -0
- package/types/ui/src/services/format.d.ts +25 -0
- package/types/ui/src/services/i18n.d.ts +18 -0
- package/types/ui/src/services/locale.d.ts +18 -0
- package/types/ui/src/services/playback.d.ts +49 -0
- package/types/ui/src/services/storyboard.d.ts +33 -0
- package/types/ui/src/services/subtitleGenerations.d.ts +13 -0
- package/types/ui/src/services/themeAudio.d.ts +19 -0
- package/types/ui/src/services/themeAudio.native.d.ts +8 -0
- package/types/ui/src/ssr.d.ts +20 -0
- package/types/ui/src/styles/motion.d.ts +2 -0
- package/types/ui/src/styles/page.d.ts +2 -0
- package/types/ui/src/styles/reset.d.ts +2 -0
- package/types/ui/src/styles/sheet.d.ts +18 -0
- package/types/ui/src/testing.d.ts +27 -0
- package/types/ui/src/workbench-config.d.ts +9 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
//! Credential resets: the token + code an admin mints for a locked-out user.
|
|
2
|
+
|
|
3
|
+
use anyhow::Result;
|
|
4
|
+
use rusqlite::{params, OptionalExtension, Row};
|
|
5
|
+
|
|
6
|
+
use crate::{now_or_blank, Pool};
|
|
7
|
+
|
|
8
|
+
pub const MAX_RESET_ATTEMPTS: i64 = 5;
|
|
9
|
+
|
|
10
|
+
pub struct CredentialReset {
|
|
11
|
+
pub token: String,
|
|
12
|
+
pub user_id: String,
|
|
13
|
+
pub code_hash: String,
|
|
14
|
+
pub attempts: i64,
|
|
15
|
+
pub created_by: Option<String>,
|
|
16
|
+
pub created_at: String,
|
|
17
|
+
pub expires_at: i64,
|
|
18
|
+
pub used_at: Option<String>,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fn row_to_reset(r: &Row) -> rusqlite::Result<CredentialReset> {
|
|
22
|
+
Ok(CredentialReset {
|
|
23
|
+
token: r.get(0)?,
|
|
24
|
+
user_id: r.get(1)?,
|
|
25
|
+
code_hash: r.get(2)?,
|
|
26
|
+
attempts: r.get(3)?,
|
|
27
|
+
created_by: r.get(4)?,
|
|
28
|
+
created_at: r.get(5)?,
|
|
29
|
+
expires_at: r.get(6)?,
|
|
30
|
+
used_at: r.get(7)?,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// Mint a reset for `user_id`, replacing any unused one. Returns the token.
|
|
35
|
+
/// Minting also answers any reset the user asked for from the sign-in screen.
|
|
36
|
+
pub fn create_reset(
|
|
37
|
+
pool: &Pool,
|
|
38
|
+
token: &str,
|
|
39
|
+
user_id: &str,
|
|
40
|
+
code_hash: &str,
|
|
41
|
+
created_by: &str,
|
|
42
|
+
expires_at: i64,
|
|
43
|
+
) -> Result<()> {
|
|
44
|
+
let conn = pool.get()?;
|
|
45
|
+
conn.execute(
|
|
46
|
+
"DELETE FROM credential_resets WHERE user_id = ?1 AND used_at IS NULL",
|
|
47
|
+
params![user_id],
|
|
48
|
+
)?;
|
|
49
|
+
conn.execute(
|
|
50
|
+
"INSERT INTO credential_resets (token,user_id,code_hash,attempts,created_by,created_at,expires_at,used_at) \
|
|
51
|
+
VALUES (?1,?2,?3,0,?4,?5,?6,NULL)",
|
|
52
|
+
params![token, user_id, code_hash, created_by, now_or_blank(), expires_at],
|
|
53
|
+
)?;
|
|
54
|
+
conn.execute(
|
|
55
|
+
"DELETE FROM reset_requests WHERE user_id = ?1",
|
|
56
|
+
params![user_id],
|
|
57
|
+
)?;
|
|
58
|
+
Ok(())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Record (or refresh) that `user_id` asked for a reset from the sign-in
|
|
62
|
+
/// screen. One open request per account: asking again just moves the date.
|
|
63
|
+
pub fn request_reset(pool: &Pool, user_id: &str) -> Result<()> {
|
|
64
|
+
let conn = pool.get()?;
|
|
65
|
+
conn.execute(
|
|
66
|
+
"INSERT INTO reset_requests (user_id,created_at) VALUES (?1,?2) \
|
|
67
|
+
ON CONFLICT(user_id) DO UPDATE SET created_at = excluded.created_at",
|
|
68
|
+
params![user_id, now_or_blank()],
|
|
69
|
+
)?;
|
|
70
|
+
Ok(())
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// Fetch one reset by token, whatever its state.
|
|
74
|
+
pub fn get_reset(pool: &Pool, token: &str) -> Result<Option<CredentialReset>> {
|
|
75
|
+
let conn = pool.get()?;
|
|
76
|
+
let reset = conn
|
|
77
|
+
.query_row(
|
|
78
|
+
"SELECT token,user_id,code_hash,attempts,created_by,created_at,expires_at,used_at \
|
|
79
|
+
FROM credential_resets WHERE token = ?1",
|
|
80
|
+
params![token],
|
|
81
|
+
row_to_reset,
|
|
82
|
+
)
|
|
83
|
+
.optional()?;
|
|
84
|
+
Ok(reset)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// Atomically consume a valid (unused, unexpired, unlocked) reset → its user id.
|
|
88
|
+
/// `None` if the token is unknown / used / expired / locked.
|
|
89
|
+
pub fn consume_reset(pool: &Pool, token: &str) -> Result<Option<String>> {
|
|
90
|
+
let conn = pool.get()?;
|
|
91
|
+
let now = time::OffsetDateTime::now_utc().unix_timestamp();
|
|
92
|
+
let user_id: Option<String> = conn
|
|
93
|
+
.query_row(
|
|
94
|
+
"UPDATE credential_resets SET used_at = ?2 \
|
|
95
|
+
WHERE token = ?1 AND used_at IS NULL AND expires_at > ?3 AND attempts < ?4 \
|
|
96
|
+
RETURNING user_id",
|
|
97
|
+
params![token, now_or_blank(), now, MAX_RESET_ATTEMPTS],
|
|
98
|
+
|r| r.get(0),
|
|
99
|
+
)
|
|
100
|
+
.optional()?;
|
|
101
|
+
Ok(user_id)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// Record a wrong code. Returns the new attempt count.
|
|
105
|
+
pub fn bump_reset_attempts(pool: &Pool, token: &str) -> Result<i64> {
|
|
106
|
+
let conn = pool.get()?;
|
|
107
|
+
let attempts: i64 = conn.query_row(
|
|
108
|
+
"UPDATE credential_resets SET attempts = attempts + 1 WHERE token = ?1 RETURNING attempts",
|
|
109
|
+
params![token],
|
|
110
|
+
|r| r.get(0),
|
|
111
|
+
)?;
|
|
112
|
+
Ok(attempts)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#[cfg(test)]
|
|
116
|
+
mod tests {
|
|
117
|
+
use super::*;
|
|
118
|
+
use crate::accounts::test_support::*;
|
|
119
|
+
|
|
120
|
+
#[test]
|
|
121
|
+
fn resets_create_get_consume_and_lock() {
|
|
122
|
+
let p = pool();
|
|
123
|
+
let owner = mk_user(&p, "o@b.c", "owner");
|
|
124
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
125
|
+
create_reset(&p, "tok1", &user.id, "code-hash", &owner.id, FUTURE).unwrap();
|
|
126
|
+
|
|
127
|
+
let got = get_reset(&p, "tok1").unwrap().unwrap();
|
|
128
|
+
assert_eq!(got.token, "tok1");
|
|
129
|
+
assert_eq!(got.user_id, user.id);
|
|
130
|
+
assert_eq!(got.attempts, 0);
|
|
131
|
+
assert!(got.used_at.is_none());
|
|
132
|
+
|
|
133
|
+
let uid = consume_reset(&p, "tok1").unwrap().unwrap();
|
|
134
|
+
assert_eq!(uid, user.id);
|
|
135
|
+
assert!(get_reset(&p, "tok1").unwrap().unwrap().used_at.is_some());
|
|
136
|
+
assert!(consume_reset(&p, "tok1").unwrap().is_none());
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#[test]
|
|
140
|
+
fn a_new_reset_replaces_the_unused_one() {
|
|
141
|
+
let p = pool();
|
|
142
|
+
let owner = mk_user(&p, "o@b.c", "owner");
|
|
143
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
144
|
+
create_reset(&p, "tok1", &user.id, "h1", &owner.id, FUTURE).unwrap();
|
|
145
|
+
create_reset(&p, "tok2", &user.id, "h2", &owner.id, FUTURE).unwrap();
|
|
146
|
+
|
|
147
|
+
assert!(get_reset(&p, "tok1").unwrap().is_none());
|
|
148
|
+
assert!(get_reset(&p, "tok2").unwrap().is_some());
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#[test]
|
|
152
|
+
fn expired_and_locked_resets_cannot_be_consumed() {
|
|
153
|
+
let p = pool();
|
|
154
|
+
let owner = mk_user(&p, "o@b.c", "owner");
|
|
155
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
156
|
+
create_reset(&p, "old", &user.id, "h", &owner.id, 1).unwrap();
|
|
157
|
+
assert!(consume_reset(&p, "old").unwrap().is_none());
|
|
158
|
+
|
|
159
|
+
create_reset(&p, "locked", &user.id, "h", &owner.id, FUTURE).unwrap();
|
|
160
|
+
for _ in 0..MAX_RESET_ATTEMPTS {
|
|
161
|
+
bump_reset_attempts(&p, "locked").unwrap();
|
|
162
|
+
}
|
|
163
|
+
assert!(consume_reset(&p, "locked").unwrap().is_none());
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
#[test]
|
|
167
|
+
fn bumping_attempts_counts_up() {
|
|
168
|
+
let p = pool();
|
|
169
|
+
let owner = mk_user(&p, "o@b.c", "owner");
|
|
170
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
171
|
+
create_reset(&p, "tok", &user.id, "h", &owner.id, FUTURE).unwrap();
|
|
172
|
+
|
|
173
|
+
assert_eq!(bump_reset_attempts(&p, "tok").unwrap(), 1);
|
|
174
|
+
assert_eq!(bump_reset_attempts(&p, "tok").unwrap(), 2);
|
|
175
|
+
assert_eq!(get_reset(&p, "tok").unwrap().unwrap().attempts, 2);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
#[test]
|
|
179
|
+
fn a_reset_request_marks_the_member_until_a_reset_is_minted() {
|
|
180
|
+
let p = pool();
|
|
181
|
+
let owner = mk_user(&p, "o@b.c", "owner");
|
|
182
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
183
|
+
assert!(!requested(&p, &user.id));
|
|
184
|
+
|
|
185
|
+
request_reset(&p, &user.id).unwrap();
|
|
186
|
+
assert!(requested(&p, &user.id));
|
|
187
|
+
request_reset(&p, &user.id).unwrap();
|
|
188
|
+
assert!(requested(&p, &user.id));
|
|
189
|
+
|
|
190
|
+
create_reset(&p, "tok", &user.id, "h", &owner.id, FUTURE).unwrap();
|
|
191
|
+
assert!(!requested(&p, &user.id));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
fn requested(p: &Pool, user_id: &str) -> bool {
|
|
195
|
+
crate::admin_users(p)
|
|
196
|
+
.unwrap()
|
|
197
|
+
.into_iter()
|
|
198
|
+
.find(|u| u.id == user_id)
|
|
199
|
+
.unwrap()
|
|
200
|
+
.reset_requested
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
//! A signed-in session, and revoking the ones that are not this device.
|
|
2
|
+
|
|
3
|
+
use anyhow::Result;
|
|
4
|
+
use rusqlite::{params, OptionalExtension};
|
|
5
|
+
|
|
6
|
+
use kroma_domain::User;
|
|
7
|
+
|
|
8
|
+
use crate::rows::row_to_user;
|
|
9
|
+
use crate::{now_or_blank, Pool};
|
|
10
|
+
|
|
11
|
+
/// `access_token` records the device credential this session was minted from,
|
|
12
|
+
/// so the account's session list can flag the current device.
|
|
13
|
+
pub fn create_session(
|
|
14
|
+
pool: &Pool,
|
|
15
|
+
token: &str,
|
|
16
|
+
user_id: &str,
|
|
17
|
+
expires_at: i64,
|
|
18
|
+
access_token: Option<&str>,
|
|
19
|
+
) -> Result<()> {
|
|
20
|
+
let conn = pool.get()?;
|
|
21
|
+
conn.execute(
|
|
22
|
+
"INSERT INTO sessions (token,user_id,created_at,expires_at,access_token) VALUES (?1,?2,?3,?4,?5)",
|
|
23
|
+
params![token, user_id, now_or_blank(), expires_at, access_token],
|
|
24
|
+
)?;
|
|
25
|
+
Ok(())
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// The non-secret `short_hash` of the device credential a live session was
|
|
29
|
+
/// minted from, so the handler never touches the raw token. `None` when the
|
|
30
|
+
/// session predates parent-token tracking.
|
|
31
|
+
pub fn session_device_id(pool: &Pool, token: &str) -> Result<Option<String>> {
|
|
32
|
+
let conn = pool.get()?;
|
|
33
|
+
let access = conn
|
|
34
|
+
.query_row(
|
|
35
|
+
"SELECT access_token FROM sessions WHERE token = ?1",
|
|
36
|
+
params![token],
|
|
37
|
+
|r| r.get::<_, Option<String>>(0),
|
|
38
|
+
)
|
|
39
|
+
.optional()?
|
|
40
|
+
.flatten();
|
|
41
|
+
Ok(access.map(|t| kroma_primitives::short_hash(&t)))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// Resolve a session token to its user; expired sessions resolve to `None`.
|
|
45
|
+
pub fn session_user(pool: &Pool, token: &str) -> Result<Option<User>> {
|
|
46
|
+
let conn = pool.get()?;
|
|
47
|
+
let now = time::OffsetDateTime::now_utc().unix_timestamp();
|
|
48
|
+
let mut stmt = conn.prepare(
|
|
49
|
+
"SELECT u.id,u.email,u.username,u.avatar_url,u.created_at,u.permissions,u.language,(u.pin_hash IS NOT NULL),u.audio_language,u.subtitle_language \
|
|
50
|
+
FROM sessions s JOIN users u ON u.id = s.user_id \
|
|
51
|
+
WHERE s.token = ?1 AND s.expires_at > ?2",
|
|
52
|
+
)?;
|
|
53
|
+
let mut rows = stmt.query_map(params![token, now], row_to_user)?;
|
|
54
|
+
match rows.next() {
|
|
55
|
+
Some(u) => Ok(Some(u?)),
|
|
56
|
+
None => Ok(None),
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
pub fn delete_session(pool: &Pool, token: &str) -> Result<()> {
|
|
61
|
+
let conn = pool.get()?;
|
|
62
|
+
conn.execute("DELETE FROM sessions WHERE token = ?1", params![token])?;
|
|
63
|
+
Ok(())
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/// Drop every session and device token except `keep_token` and the device it
|
|
67
|
+
/// was minted from, so a rotated password evicts any stolen credential while
|
|
68
|
+
/// the caller stays signed in. An unknown `keep_token` revokes everything
|
|
69
|
+
/// (fail-closed).
|
|
70
|
+
pub fn revoke_other_sessions(pool: &Pool, user_id: &str, keep_token: &str) -> Result<()> {
|
|
71
|
+
let conn = pool.get()?;
|
|
72
|
+
let keep_device: Option<String> = conn
|
|
73
|
+
.query_row(
|
|
74
|
+
"SELECT access_token FROM sessions WHERE token = ?1",
|
|
75
|
+
params![keep_token],
|
|
76
|
+
|r| r.get::<_, Option<String>>(0),
|
|
77
|
+
)
|
|
78
|
+
.optional()?
|
|
79
|
+
.flatten();
|
|
80
|
+
conn.execute(
|
|
81
|
+
"DELETE FROM sessions WHERE user_id = ?1 AND token <> ?2",
|
|
82
|
+
params![user_id, keep_token],
|
|
83
|
+
)?;
|
|
84
|
+
match keep_device {
|
|
85
|
+
Some(dev) => conn.execute(
|
|
86
|
+
"DELETE FROM access_tokens WHERE user_id = ?1 AND token <> ?2",
|
|
87
|
+
params![user_id, dev],
|
|
88
|
+
)?,
|
|
89
|
+
None => conn.execute(
|
|
90
|
+
"DELETE FROM access_tokens WHERE user_id = ?1",
|
|
91
|
+
params![user_id],
|
|
92
|
+
)?,
|
|
93
|
+
};
|
|
94
|
+
Ok(())
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// Drop every session and device token for the user. A completed credential
|
|
98
|
+
/// reset evicts everything, so a stolen credential dies with the old password.
|
|
99
|
+
pub fn revoke_all_sessions(pool: &Pool, user_id: &str) -> Result<()> {
|
|
100
|
+
let conn = pool.get()?;
|
|
101
|
+
conn.execute("DELETE FROM sessions WHERE user_id = ?1", params![user_id])?;
|
|
102
|
+
conn.execute(
|
|
103
|
+
"DELETE FROM access_tokens WHERE user_id = ?1",
|
|
104
|
+
params![user_id],
|
|
105
|
+
)?;
|
|
106
|
+
Ok(())
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
#[cfg(test)]
|
|
110
|
+
mod tests {
|
|
111
|
+
use super::*;
|
|
112
|
+
use crate::accounts::test_support::*;
|
|
113
|
+
use crate::accounts::{access_token_user, create_access_token, list_access_tokens};
|
|
114
|
+
|
|
115
|
+
#[test]
|
|
116
|
+
fn sessions_resolve_and_expire() {
|
|
117
|
+
let p = pool();
|
|
118
|
+
let u = mk_user(&p, "a@b.c", "alice");
|
|
119
|
+
create_session(&p, "sess-tok", &u.id, FUTURE, Some("acc-tok")).unwrap();
|
|
120
|
+
assert_eq!(session_user(&p, "sess-tok").unwrap().unwrap().id, u.id);
|
|
121
|
+
assert_eq!(
|
|
122
|
+
session_device_id(&p, "sess-tok").unwrap(),
|
|
123
|
+
Some(kroma_primitives::short_hash("acc-tok"))
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
create_session(&p, "old-sess", &u.id, 1, None).unwrap();
|
|
127
|
+
assert!(session_user(&p, "old-sess").unwrap().is_none());
|
|
128
|
+
assert!(session_device_id(&p, "old-sess").unwrap().is_none());
|
|
129
|
+
|
|
130
|
+
delete_session(&p, "sess-tok").unwrap();
|
|
131
|
+
assert!(session_user(&p, "sess-tok").unwrap().is_none());
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
#[test]
|
|
135
|
+
fn revoking_other_sessions_keeps_the_caller_and_the_device_it_came_from() {
|
|
136
|
+
let p = pool();
|
|
137
|
+
let user = mk_user(&p, "a@b.c", "alice");
|
|
138
|
+
|
|
139
|
+
create_access_token(&p, "dev-phone", &user.id, FUTURE, true, Some("iPhone")).unwrap();
|
|
140
|
+
create_access_token(&p, "dev-laptop", &user.id, FUTURE, true, Some("Mac")).unwrap();
|
|
141
|
+
create_session(&p, "sess-phone", &user.id, FUTURE, Some("dev-phone")).unwrap();
|
|
142
|
+
create_session(&p, "sess-laptop", &user.id, FUTURE, Some("dev-laptop")).unwrap();
|
|
143
|
+
|
|
144
|
+
revoke_other_sessions(&p, &user.id, "sess-phone").unwrap();
|
|
145
|
+
|
|
146
|
+
assert!(session_user(&p, "sess-phone").unwrap().is_some());
|
|
147
|
+
assert!(session_user(&p, "sess-laptop").unwrap().is_none());
|
|
148
|
+
assert!(access_token_user(&p, "dev-phone").unwrap().is_some());
|
|
149
|
+
assert!(access_token_user(&p, "dev-laptop").unwrap().is_none());
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
#[test]
|
|
153
|
+
fn an_unknown_keep_token_revokes_every_device_credential() {
|
|
154
|
+
let p = pool();
|
|
155
|
+
let user = mk_user(&p, "a@b.c", "alice");
|
|
156
|
+
create_access_token(&p, "dev-phone", &user.id, FUTURE, true, Some("iPhone")).unwrap();
|
|
157
|
+
create_session(&p, "sess-phone", &user.id, FUTURE, Some("dev-phone")).unwrap();
|
|
158
|
+
|
|
159
|
+
revoke_other_sessions(&p, &user.id, "sess-gone").unwrap();
|
|
160
|
+
|
|
161
|
+
assert!(session_user(&p, "sess-phone").unwrap().is_none());
|
|
162
|
+
assert!(access_token_user(&p, "dev-phone").unwrap().is_none());
|
|
163
|
+
assert!(list_access_tokens(&p, &user.id).unwrap().is_empty());
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
#[test]
|
|
167
|
+
fn revoke_all_sessions_evicts_everything() {
|
|
168
|
+
let p = pool();
|
|
169
|
+
let user = mk_user(&p, "a@b.c", "alice");
|
|
170
|
+
create_access_token(&p, "dev-phone", &user.id, FUTURE, true, Some("iPhone")).unwrap();
|
|
171
|
+
create_access_token(&p, "dev-laptop", &user.id, FUTURE, true, Some("Mac")).unwrap();
|
|
172
|
+
create_session(&p, "sess-phone", &user.id, FUTURE, Some("dev-phone")).unwrap();
|
|
173
|
+
create_session(&p, "sess-laptop", &user.id, FUTURE, Some("dev-laptop")).unwrap();
|
|
174
|
+
|
|
175
|
+
revoke_all_sessions(&p, &user.id).unwrap();
|
|
176
|
+
|
|
177
|
+
assert!(session_user(&p, "sess-phone").unwrap().is_none());
|
|
178
|
+
assert!(session_user(&p, "sess-laptop").unwrap().is_none());
|
|
179
|
+
assert!(access_token_user(&p, "dev-phone").unwrap().is_none());
|
|
180
|
+
assert!(access_token_user(&p, "dev-laptop").unwrap().is_none());
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
use super::create_user;
|
|
2
|
+
use crate::testing::TempPool;
|
|
3
|
+
use crate::Pool;
|
|
4
|
+
use kroma_domain::{Permission, User};
|
|
5
|
+
|
|
6
|
+
pub(super) const FUTURE: i64 = 9_999_999_999;
|
|
7
|
+
|
|
8
|
+
pub(super) fn pool() -> TempPool {
|
|
9
|
+
crate::testing::temp_pool("acct")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
pub(super) fn mk_user(pool: &Pool, email: &str, username: &str) -> User {
|
|
13
|
+
create_user(pool, email, username, "hash", &[Permission::Playback]).unwrap()
|
|
14
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
//! Email verifications: the single-use link an admin mints so an address proves
|
|
2
|
+
//! its mailbox. Unlike a credential reset there is no code: reaching the mailbox
|
|
3
|
+
//! is itself the proof, so the link alone suffices. The row pins the address it
|
|
4
|
+
//! was minted for, and confirming verifies nothing once the account's address no
|
|
5
|
+
//! longer matches it (ADMIN-87).
|
|
6
|
+
|
|
7
|
+
use anyhow::Result;
|
|
8
|
+
use rusqlite::{params, OptionalExtension, Row};
|
|
9
|
+
|
|
10
|
+
use crate::{now_or_blank, Pool};
|
|
11
|
+
|
|
12
|
+
pub struct EmailVerification {
|
|
13
|
+
pub token: String,
|
|
14
|
+
pub user_id: String,
|
|
15
|
+
pub email: String,
|
|
16
|
+
pub created_by: Option<String>,
|
|
17
|
+
pub created_at: String,
|
|
18
|
+
pub expires_at: i64,
|
|
19
|
+
pub used_at: Option<String>,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fn row_to_verification(r: &Row) -> rusqlite::Result<EmailVerification> {
|
|
23
|
+
Ok(EmailVerification {
|
|
24
|
+
token: r.get(0)?,
|
|
25
|
+
user_id: r.get(1)?,
|
|
26
|
+
email: r.get(2)?,
|
|
27
|
+
created_by: r.get(3)?,
|
|
28
|
+
created_at: r.get(4)?,
|
|
29
|
+
expires_at: r.get(5)?,
|
|
30
|
+
used_at: r.get(6)?,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// Mint a verification for `user_id`'s current address, replacing any unused one.
|
|
35
|
+
pub fn create_verification(
|
|
36
|
+
pool: &Pool,
|
|
37
|
+
token: &str,
|
|
38
|
+
user_id: &str,
|
|
39
|
+
email: &str,
|
|
40
|
+
created_by: &str,
|
|
41
|
+
expires_at: i64,
|
|
42
|
+
) -> Result<()> {
|
|
43
|
+
let conn = pool.get()?;
|
|
44
|
+
conn.execute(
|
|
45
|
+
"DELETE FROM email_verifications WHERE user_id = ?1 AND used_at IS NULL",
|
|
46
|
+
params![user_id],
|
|
47
|
+
)?;
|
|
48
|
+
conn.execute(
|
|
49
|
+
"INSERT INTO email_verifications (token,user_id,email,created_by,created_at,expires_at,used_at) \
|
|
50
|
+
VALUES (?1,?2,?3,?4,?5,?6,NULL)",
|
|
51
|
+
params![token, user_id, email, created_by, now_or_blank(), expires_at],
|
|
52
|
+
)?;
|
|
53
|
+
Ok(())
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// Fetch one verification by token, whatever its state.
|
|
57
|
+
pub fn get_verification(pool: &Pool, token: &str) -> Result<Option<EmailVerification>> {
|
|
58
|
+
let conn = pool.get()?;
|
|
59
|
+
let v = conn
|
|
60
|
+
.query_row(
|
|
61
|
+
"SELECT token,user_id,email,created_by,created_at,expires_at,used_at \
|
|
62
|
+
FROM email_verifications WHERE token = ?1",
|
|
63
|
+
params![token],
|
|
64
|
+
row_to_verification,
|
|
65
|
+
)
|
|
66
|
+
.optional()?;
|
|
67
|
+
Ok(v)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// Confirm a verification: mark the address verified and the token used, only
|
|
71
|
+
/// while the token is unused, unexpired and the account's address is still the
|
|
72
|
+
/// one the link was minted for. Returns the verified user id, or `None`.
|
|
73
|
+
pub fn confirm_verification(pool: &Pool, token: &str) -> Result<Option<String>> {
|
|
74
|
+
let conn = pool.get()?;
|
|
75
|
+
let now = time::OffsetDateTime::now_utc().unix_timestamp();
|
|
76
|
+
let user_id: Option<String> = conn
|
|
77
|
+
.query_row(
|
|
78
|
+
"UPDATE users SET email_verified_at = ?2 \
|
|
79
|
+
WHERE id = (SELECT user_id FROM email_verifications \
|
|
80
|
+
WHERE token = ?1 AND used_at IS NULL AND expires_at > ?2) \
|
|
81
|
+
AND email = (SELECT email FROM email_verifications WHERE token = ?1) \
|
|
82
|
+
RETURNING id",
|
|
83
|
+
params![token, now],
|
|
84
|
+
|r| r.get(0),
|
|
85
|
+
)
|
|
86
|
+
.optional()?;
|
|
87
|
+
if user_id.is_some() {
|
|
88
|
+
conn.execute(
|
|
89
|
+
"UPDATE email_verifications SET used_at = ?2 WHERE token = ?1",
|
|
90
|
+
params![token, now_or_blank()],
|
|
91
|
+
)?;
|
|
92
|
+
}
|
|
93
|
+
Ok(user_id)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// Set or clear the address's proof of ownership directly.
|
|
97
|
+
pub fn set_email_verified(pool: &Pool, user_id: &str, verified: bool) -> Result<()> {
|
|
98
|
+
let conn = pool.get()?;
|
|
99
|
+
let at = verified.then(now_or_blank);
|
|
100
|
+
conn.execute(
|
|
101
|
+
"UPDATE users SET email_verified_at = ?2 WHERE id = ?1",
|
|
102
|
+
params![user_id, at],
|
|
103
|
+
)?;
|
|
104
|
+
Ok(())
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#[cfg(test)]
|
|
108
|
+
mod tests {
|
|
109
|
+
use super::*;
|
|
110
|
+
use crate::accounts::test_support::*;
|
|
111
|
+
|
|
112
|
+
#[test]
|
|
113
|
+
fn verifications_create_get_and_confirm() {
|
|
114
|
+
let p = pool();
|
|
115
|
+
let owner = mk_user(&p, "o@b.c", "owner");
|
|
116
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
117
|
+
create_verification(&p, "tok1", &user.id, "u@b.c", &owner.id, FUTURE).unwrap();
|
|
118
|
+
|
|
119
|
+
let got = get_verification(&p, "tok1").unwrap().unwrap();
|
|
120
|
+
assert_eq!(got.user_id, user.id);
|
|
121
|
+
assert_eq!(got.email, "u@b.c");
|
|
122
|
+
assert!(got.used_at.is_none());
|
|
123
|
+
|
|
124
|
+
let uid = confirm_verification(&p, "tok1").unwrap().unwrap();
|
|
125
|
+
assert_eq!(uid, user.id);
|
|
126
|
+
assert!(get_verification(&p, "tok1").unwrap().unwrap().used_at.is_some());
|
|
127
|
+
assert!(confirm_verification(&p, "tok1").unwrap().is_none());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
#[test]
|
|
131
|
+
fn a_new_verification_replaces_the_unused_one() {
|
|
132
|
+
let p = pool();
|
|
133
|
+
let owner = mk_user(&p, "o@b.c", "owner");
|
|
134
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
135
|
+
create_verification(&p, "tok1", &user.id, "u@b.c", &owner.id, FUTURE).unwrap();
|
|
136
|
+
create_verification(&p, "tok2", &user.id, "u@b.c", &owner.id, FUTURE).unwrap();
|
|
137
|
+
|
|
138
|
+
assert!(get_verification(&p, "tok1").unwrap().is_none());
|
|
139
|
+
assert!(get_verification(&p, "tok2").unwrap().is_some());
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#[test]
|
|
143
|
+
fn an_expired_verification_cannot_be_confirmed() {
|
|
144
|
+
let p = pool();
|
|
145
|
+
let owner = mk_user(&p, "o@b.c", "owner");
|
|
146
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
147
|
+
create_verification(&p, "old", &user.id, "u@b.c", &owner.id, 1).unwrap();
|
|
148
|
+
|
|
149
|
+
assert!(confirm_verification(&p, "old").unwrap().is_none());
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
#[test]
|
|
153
|
+
fn a_changed_address_verifies_nothing() {
|
|
154
|
+
let p = pool();
|
|
155
|
+
let owner = mk_user(&p, "o@b.c", "owner");
|
|
156
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
157
|
+
create_verification(&p, "tok", &user.id, "u@b.c", &owner.id, FUTURE).unwrap();
|
|
158
|
+
crate::accounts::set_user_email(&p, &user.id, "new@b.c").unwrap();
|
|
159
|
+
|
|
160
|
+
assert!(confirm_verification(&p, "tok").unwrap().is_none());
|
|
161
|
+
assert!(get_verification(&p, "tok").unwrap().unwrap().used_at.is_none());
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#[test]
|
|
165
|
+
fn changing_the_address_clears_the_verified_state() {
|
|
166
|
+
let p = pool();
|
|
167
|
+
let user = mk_user(&p, "u@b.c", "user");
|
|
168
|
+
set_email_verified(&p, &user.id, true).unwrap();
|
|
169
|
+
assert!(email_verified(&p, &user.id));
|
|
170
|
+
|
|
171
|
+
crate::accounts::set_user_email(&p, &user.id, "new@b.c").unwrap();
|
|
172
|
+
assert!(!email_verified(&p, &user.id));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
fn email_verified(p: &Pool, id: &str) -> bool {
|
|
176
|
+
p.get()
|
|
177
|
+
.unwrap()
|
|
178
|
+
.query_row(
|
|
179
|
+
"SELECT email_verified_at IS NOT NULL FROM users WHERE id = ?1",
|
|
180
|
+
params![id],
|
|
181
|
+
|r| r.get(0),
|
|
182
|
+
)
|
|
183
|
+
.unwrap()
|
|
184
|
+
}
|
|
185
|
+
}
|