Compare commits
28
Commits
0.1.2
...
842c4c9b0c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
842c4c9b0c | ||
|
|
58200b2bf9 | ||
|
|
35de0e1990 | ||
|
|
975cf38170 | ||
|
|
ab46e63bf0 | ||
|
|
3f7414707a | ||
|
|
cd99cd20df | ||
|
|
8bb0471a71 | ||
|
|
f24d8aa062 | ||
|
|
5233b1e6fd | ||
|
|
ff9f679fcb | ||
|
|
a13bc17629 | ||
|
|
f480407927 | ||
|
|
9267786371 | ||
|
|
e24f4ff7e2 | ||
|
|
56cd6e32e9 | ||
|
|
689bd95ff0 | ||
|
|
240d993d57 | ||
|
|
c2f6b07742 | ||
|
|
863d43ef8c | ||
|
|
dcd1203d31 | ||
|
|
5638fc4979 | ||
|
|
3695fc68d6 | ||
|
|
cf6853d71e | ||
|
|
fdbf40adac | ||
|
|
a6482ddb0e | ||
|
|
3160a898be | ||
|
|
209363774c |
@@ -1,17 +0,0 @@
|
|||||||
when:
|
|
||||||
event: [push, pull_request]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
e2e-build:
|
|
||||||
image: rust:1
|
|
||||||
commands:
|
|
||||||
- cargo build
|
|
||||||
|
|
||||||
e2e-test:
|
|
||||||
image: node:24
|
|
||||||
directory: e2e
|
|
||||||
commands:
|
|
||||||
- apt-get update
|
|
||||||
- apt-get install -y --no-install-recommends ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libcups2 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 xdg-utils
|
|
||||||
- npm install && npx playwright install chromium
|
|
||||||
- npx playwright test
|
|
||||||
@@ -6,3 +6,13 @@ steps:
|
|||||||
image: rust:1
|
image: rust:1
|
||||||
commands:
|
commands:
|
||||||
- cargo test --all
|
- cargo test --all
|
||||||
|
- cargo build --all
|
||||||
|
|
||||||
|
e2e-test:
|
||||||
|
image: node:24
|
||||||
|
directory: e2e
|
||||||
|
commands:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get install -y --no-install-recommends ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libcups2 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 xdg-utils
|
||||||
|
- npm install && npx playwright install chromium
|
||||||
|
- npx playwright test
|
||||||
|
|||||||
Generated
+447
-10
@@ -116,6 +116,12 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "barcoders"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a3826fb6e98ec72c0c0db8c9a40af4932d16793021027469857e84c1b50a1e8f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.13.1"
|
version = "0.13.1"
|
||||||
@@ -139,6 +145,9 @@ name = "bitflags"
|
|||||||
version = "2.13.1"
|
version = "2.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
|
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
|
||||||
|
dependencies = [
|
||||||
|
"serde_core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blake2"
|
name = "blake2"
|
||||||
@@ -158,6 +167,12 @@ dependencies = [
|
|||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.12.1"
|
version = "1.12.1"
|
||||||
@@ -180,6 +195,12 @@ version = "1.0.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const-oid"
|
||||||
|
version = "0.9.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
@@ -235,6 +256,17 @@ version = "2.11.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8"
|
checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "der"
|
||||||
|
version = "0.7.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"
|
||||||
|
dependencies = [
|
||||||
|
"const-oid",
|
||||||
|
"pem-rfc7468",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.10.7"
|
version = "0.10.7"
|
||||||
@@ -242,6 +274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block-buffer",
|
"block-buffer",
|
||||||
|
"const-oid",
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
@@ -288,6 +321,17 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "etcetera"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"home",
|
||||||
|
"windows-sys 0.48.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "event-listener"
|
name = "event-listener"
|
||||||
version = "5.4.2"
|
version = "5.4.2"
|
||||||
@@ -514,6 +558,33 @@ version = "0.4.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hkdf"
|
||||||
|
version = "0.12.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
|
||||||
|
dependencies = [
|
||||||
|
"hmac",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hmac"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
|
||||||
|
dependencies = [
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "home"
|
||||||
|
version = "0.5.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys 0.61.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http"
|
name = "http"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
@@ -724,6 +795,9 @@ name = "lazy_static"
|
|||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
dependencies = [
|
||||||
|
"spin",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
@@ -731,6 +805,24 @@ version = "0.2.189"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libm"
|
||||||
|
version = "0.2.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libredox"
|
||||||
|
version = "0.1.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c943259e342f1e06ff2da7a83eabdfe7f92ce10262688dbf1895ff0b3e6e4652"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"libc",
|
||||||
|
"plain",
|
||||||
|
"redox_syscall 0.9.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
version = "0.30.1"
|
version = "0.30.1"
|
||||||
@@ -800,6 +892,16 @@ dependencies = [
|
|||||||
"syn 2.0.119",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "md-5"
|
||||||
|
version = "0.10.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.8.3"
|
version = "2.8.3"
|
||||||
@@ -858,6 +960,41 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-bigint-dig"
|
||||||
|
version = "0.8.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"libm",
|
||||||
|
"num-integer",
|
||||||
|
"num-iter",
|
||||||
|
"num-traits",
|
||||||
|
"rand 0.8.7",
|
||||||
|
"smallvec",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-integer"
|
||||||
|
version = "0.1.46"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-iter"
|
||||||
|
version = "0.1.46"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b"
|
||||||
|
dependencies = [
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.19"
|
version = "0.2.19"
|
||||||
@@ -865,6 +1002,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
|
"libm",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -934,7 +1072,7 @@ checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall 0.5.18",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"windows-link",
|
"windows-link",
|
||||||
]
|
]
|
||||||
@@ -950,6 +1088,15 @@ dependencies = [
|
|||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pem-rfc7468"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412"
|
||||||
|
dependencies = [
|
||||||
|
"base64ct",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.3.2"
|
version = "2.3.2"
|
||||||
@@ -962,12 +1109,39 @@ version = "0.2.17"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkcs1"
|
||||||
|
version = "0.7.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f"
|
||||||
|
dependencies = [
|
||||||
|
"der",
|
||||||
|
"pkcs8",
|
||||||
|
"spki",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkcs8"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
|
||||||
|
dependencies = [
|
||||||
|
"der",
|
||||||
|
"spki",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg-config"
|
name = "pkg-config"
|
||||||
version = "0.3.33"
|
version = "0.3.33"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e"
|
checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plain"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "potential_utf"
|
name = "potential_utf"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
@@ -1109,6 +1283,15 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_syscall"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "07507be7b4a5f9f26eeb41eeaebb1f5a7ff29dfb29739facc21d35bf8b11c21e"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.4.16"
|
version = "0.4.16"
|
||||||
@@ -1140,6 +1323,26 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rsa"
|
||||||
|
version = "0.9.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d"
|
||||||
|
dependencies = [
|
||||||
|
"const-oid",
|
||||||
|
"digest",
|
||||||
|
"num-bigint-dig",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
"pkcs1",
|
||||||
|
"pkcs8",
|
||||||
|
"rand_core 0.6.4",
|
||||||
|
"signature",
|
||||||
|
"spki",
|
||||||
|
"subtle",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.23.43"
|
version = "0.23.43"
|
||||||
@@ -1309,6 +1512,16 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "signature"
|
||||||
|
version = "2.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
||||||
|
dependencies = [
|
||||||
|
"digest",
|
||||||
|
"rand_core 0.6.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.12"
|
version = "0.4.12"
|
||||||
@@ -1320,6 +1533,9 @@ name = "smallvec"
|
|||||||
version = "1.15.2"
|
version = "1.15.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
|
checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
@@ -1340,6 +1556,16 @@ dependencies = [
|
|||||||
"lock_api",
|
"lock_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spki"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
|
||||||
|
dependencies = [
|
||||||
|
"base64ct",
|
||||||
|
"der",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sqlx"
|
name = "sqlx"
|
||||||
version = "0.8.6"
|
version = "0.8.6"
|
||||||
@@ -1348,6 +1574,8 @@ checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"sqlx-macros",
|
"sqlx-macros",
|
||||||
|
"sqlx-mysql",
|
||||||
|
"sqlx-postgres",
|
||||||
"sqlx-sqlite",
|
"sqlx-sqlite",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1376,6 +1604,7 @@ dependencies = [
|
|||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"rustls",
|
"rustls",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thiserror 2.0.19",
|
"thiserror 2.0.19",
|
||||||
@@ -1422,6 +1651,84 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sqlx-mysql"
|
||||||
|
version = "0.8.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526"
|
||||||
|
dependencies = [
|
||||||
|
"atoi",
|
||||||
|
"base64 0.22.1",
|
||||||
|
"bitflags",
|
||||||
|
"byteorder",
|
||||||
|
"bytes",
|
||||||
|
"crc",
|
||||||
|
"digest",
|
||||||
|
"dotenvy",
|
||||||
|
"either",
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
|
"futures-util",
|
||||||
|
"generic-array",
|
||||||
|
"hex",
|
||||||
|
"hkdf",
|
||||||
|
"hmac",
|
||||||
|
"itoa",
|
||||||
|
"log",
|
||||||
|
"md-5",
|
||||||
|
"memchr",
|
||||||
|
"once_cell",
|
||||||
|
"percent-encoding",
|
||||||
|
"rand 0.8.7",
|
||||||
|
"rsa",
|
||||||
|
"sha1",
|
||||||
|
"sha2",
|
||||||
|
"smallvec",
|
||||||
|
"sqlx-core",
|
||||||
|
"stringprep",
|
||||||
|
"thiserror 2.0.19",
|
||||||
|
"tracing",
|
||||||
|
"whoami",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sqlx-postgres"
|
||||||
|
version = "0.8.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46"
|
||||||
|
dependencies = [
|
||||||
|
"atoi",
|
||||||
|
"base64 0.22.1",
|
||||||
|
"bitflags",
|
||||||
|
"byteorder",
|
||||||
|
"crc",
|
||||||
|
"dotenvy",
|
||||||
|
"etcetera",
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-util",
|
||||||
|
"hex",
|
||||||
|
"hkdf",
|
||||||
|
"hmac",
|
||||||
|
"home",
|
||||||
|
"itoa",
|
||||||
|
"log",
|
||||||
|
"md-5",
|
||||||
|
"memchr",
|
||||||
|
"once_cell",
|
||||||
|
"rand 0.8.7",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sha2",
|
||||||
|
"smallvec",
|
||||||
|
"sqlx-core",
|
||||||
|
"stringprep",
|
||||||
|
"thiserror 2.0.19",
|
||||||
|
"tracing",
|
||||||
|
"whoami",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sqlx-sqlite"
|
name = "sqlx-sqlite"
|
||||||
version = "0.8.6"
|
version = "0.8.6"
|
||||||
@@ -1452,6 +1759,17 @@ version = "1.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
|
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stringprep"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-bidi",
|
||||||
|
"unicode-normalization",
|
||||||
|
"unicode-properties",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.6.1"
|
version = "2.6.1"
|
||||||
@@ -1460,11 +1778,12 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sustenance"
|
name = "sustenance"
|
||||||
version = "0.1.2"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
|
"barcoders",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hex",
|
"hex",
|
||||||
@@ -1583,6 +1902,21 @@ dependencies = [
|
|||||||
"zerovec",
|
"zerovec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinyvec"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bb4ebadaa0af04fab11ae01eb5f9fdb5f9c5b875506e210e71c07873528baa7f"
|
||||||
|
dependencies = [
|
||||||
|
"tinyvec_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinyvec_macros"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.53.1"
|
version = "1.53.1"
|
||||||
@@ -1791,12 +2125,33 @@ version = "2.9.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
|
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-bidi"
|
||||||
|
version = "0.3.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.24"
|
version = "1.0.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-normalization"
|
||||||
|
version = "0.1.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8"
|
||||||
|
dependencies = [
|
||||||
|
"tinyvec",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-properties"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-width"
|
name = "unicode-width"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@@ -1861,6 +2216,12 @@ dependencies = [
|
|||||||
"wit-bindgen",
|
"wit-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasite"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webauthn-rs"
|
name = "webauthn-rs"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
@@ -1898,19 +2259,38 @@ dependencies = [
|
|||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "whoami"
|
||||||
|
version = "1.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d"
|
||||||
|
dependencies = [
|
||||||
|
"libredox",
|
||||||
|
"wasite",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-link"
|
name = "windows-link"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.48.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.48.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1922,34 +2302,67 @@ dependencies = [
|
|||||||
"windows-link",
|
"windows-link",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm 0.48.5",
|
||||||
|
"windows_aarch64_msvc 0.48.5",
|
||||||
|
"windows_i686_gnu 0.48.5",
|
||||||
|
"windows_i686_msvc 0.48.5",
|
||||||
|
"windows_x86_64_gnu 0.48.5",
|
||||||
|
"windows_x86_64_gnullvm 0.48.5",
|
||||||
|
"windows_x86_64_msvc 0.48.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm 0.52.6",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc 0.52.6",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu 0.52.6",
|
||||||
"windows_i686_gnullvm",
|
"windows_i686_gnullvm",
|
||||||
"windows_i686_msvc",
|
"windows_i686_msvc 0.52.6",
|
||||||
"windows_x86_64_gnu",
|
"windows_x86_64_gnu 0.52.6",
|
||||||
"windows_x86_64_gnullvm",
|
"windows_x86_64_gnullvm 0.52.6",
|
||||||
"windows_x86_64_msvc",
|
"windows_x86_64_msvc 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_gnullvm"
|
name = "windows_aarch64_gnullvm"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
@@ -1962,24 +2375,48 @@ version = "0.52.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
|
|||||||
+3
-2
@@ -1,12 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sustenance"
|
name = "sustenance"
|
||||||
version = "0.1.2"
|
version = "0.4.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
argon2 = "0.5"
|
argon2 = "0.5"
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
axum = { version = "0.8", features = ["ws"] }
|
axum = { version = "0.8", features = ["ws"] }
|
||||||
|
barcoders = { version = "2.0.0", features = ["svg"] }
|
||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
@@ -16,7 +17,7 @@ rand = "0.8"
|
|||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio", "sqlite", "macros", "tls-rustls"] }
|
sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio", "sqlite", "macros", "migrate", "tls-rustls"] }
|
||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
tower = "0.5"
|
tower = "0.5"
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ The file is optional — if it is missing or invalid, seeding is silently skippe
|
|||||||
- Global categories with common defaults seeded at startup and custom category creation
|
- Global categories with common defaults seeded at startup and custom category creation
|
||||||
- Items grouped by category and assigned from the add/edit forms
|
- Items grouped by category and assigned from the add/edit forms
|
||||||
- Meals with ingredients, markdown descriptions, and one-click "add meal to list"
|
- Meals with ingredients, markdown descriptions, and one-click "add meal to list"
|
||||||
|
- Rewards cards with store name and number, rendered as scannable Code 128 / Code 39 barcodes
|
||||||
|
- Single-card scan view that shows one barcode at a time and keeps the screen awake for scanning
|
||||||
- Server-authoritative last-write-wins updates
|
- Server-authoritative last-write-wins updates
|
||||||
- Per-list WebSocket updates with server-rendered htmx fragments
|
- Per-list WebSocket updates with server-rendered htmx fragments
|
||||||
- In-memory presence for members currently viewing a list
|
- In-memory presence for members currently viewing a list
|
||||||
|
|||||||
+5
-19
@@ -1,13 +1,12 @@
|
|||||||
import { test as base, expect, Page } from "@playwright/test";
|
import { test as base, expect, Page } from "@playwright/test";
|
||||||
import { spawn, ChildProcess } from "child_process";
|
import { spawn, ChildProcess } from "child_process";
|
||||||
import * as fs from "fs";
|
|
||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a fresh Sustenance server against a unique, throwaway database on a
|
* Starts a fresh Sustenance server against an in-memory SQLite database on a
|
||||||
* unique port for each test, and tears it down afterwards. This gives every
|
* unique port for each test, and tears it down afterwards. Every test gets a
|
||||||
* test a clean DB with no shared state between tests.
|
* clean DB with no shared state between tests, and nothing is written to disk.
|
||||||
*/
|
*/
|
||||||
export const test = base.extend<{ server: { baseURL: string }; page: Page }>({
|
export const test = base.extend<{ server: { baseURL: string }; page: Page }>({
|
||||||
server: [
|
server: [
|
||||||
@@ -15,10 +14,6 @@ export const test = base.extend<{ server: { baseURL: string }; page: Page }>({
|
|||||||
const server = await startServer();
|
const server = await startServer();
|
||||||
await use({ baseURL: server.baseURL });
|
await use({ baseURL: server.baseURL });
|
||||||
await killTree(server.child);
|
await killTree(server.child);
|
||||||
// Clean up the DB files (including -wal / -shm).
|
|
||||||
for (const suffix of ["", "-wal", "-shm"]) {
|
|
||||||
fs.rmSync(server.dbPath + suffix, { force: true });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{ scope: "test", auto: true },
|
{ scope: "test", auto: true },
|
||||||
],
|
],
|
||||||
@@ -35,12 +30,6 @@ export const test = base.extend<{ server: { baseURL: string }; page: Page }>({
|
|||||||
/** Starts a server, retrying on a fresh port if the first attempt fails to bind. */
|
/** Starts a server, retrying on a fresh port if the first attempt fails to bind. */
|
||||||
async function startServer() {
|
async function startServer() {
|
||||||
for (let attempt = 0; attempt < 5; attempt++) {
|
for (let attempt = 0; attempt < 5; attempt++) {
|
||||||
const dbPath = path.join(
|
|
||||||
os.tmpdir(),
|
|
||||||
`sustenance-e2e-${process.pid}-${Date.now()}-${Math.random()
|
|
||||||
.toString(36)
|
|
||||||
.slice(2)}.db`,
|
|
||||||
);
|
|
||||||
const port = 20000 + Math.floor(Math.random() * 30000);
|
const port = 20000 + Math.floor(Math.random() * 30000);
|
||||||
const baseURL = `http://localhost:${port}`;
|
const baseURL = `http://localhost:${port}`;
|
||||||
|
|
||||||
@@ -50,7 +39,7 @@ async function startServer() {
|
|||||||
{
|
{
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
DATABASE_PATH: dbPath,
|
DATABASE_IN_MEMORY: "1",
|
||||||
REGISTRATION_MODE: "open",
|
REGISTRATION_MODE: "open",
|
||||||
BIND_ADDRESS: `127.0.0.1:${port}`,
|
BIND_ADDRESS: `127.0.0.1:${port}`,
|
||||||
PUBLIC_BASE_URL: baseURL,
|
PUBLIC_BASE_URL: baseURL,
|
||||||
@@ -72,13 +61,10 @@ async function startServer() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await waitForServer(baseURL, child);
|
await waitForServer(baseURL, child);
|
||||||
return { baseURL, child, dbPath };
|
return { baseURL, child };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// The server may have failed to bind (port collision). Clean up and retry.
|
// The server may have failed to bind (port collision). Clean up and retry.
|
||||||
await killTree(child);
|
await killTree(child);
|
||||||
for (const suffix of ["", "-wal", "-shm"]) {
|
|
||||||
fs.rmSync(dbPath + suffix, { force: true });
|
|
||||||
}
|
|
||||||
if (attempt === 4) {
|
if (attempt === 4) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`server failed to start after retries; last stderr:\n${stderr}\n${error}`,
|
`server failed to start after retries; last stderr:\n${stderr}\n${error}`,
|
||||||
|
|||||||
+21
-2
@@ -11,9 +11,17 @@ export async function registerAndLogin(page: Page, email: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a meal with the given name and markdown description. */
|
/** Creates a meal with the given name and markdown description. */
|
||||||
export async function createMeal(page: Page, name: string, description: string) {
|
export async function createMeal(
|
||||||
|
page: Page,
|
||||||
|
name: string,
|
||||||
|
description: string,
|
||||||
|
category?: string,
|
||||||
|
) {
|
||||||
await page.goto("/meals/new");
|
await page.goto("/meals/new");
|
||||||
await page.fill("#meal-name", name);
|
await page.fill("#meal-name", name);
|
||||||
|
if (category) {
|
||||||
|
await page.selectOption("#meal-category", { label: category });
|
||||||
|
}
|
||||||
await page.fill("#meal-description", description);
|
await page.fill("#meal-description", description);
|
||||||
await page.click('button:has-text("Save meal")');
|
await page.click('button:has-text("Save meal")');
|
||||||
await expect(page).toHaveURL(/\/meals\/\d+/);
|
await expect(page).toHaveURL(/\/meals\/\d+/);
|
||||||
@@ -38,12 +46,23 @@ export async function addItem(page: Page, name: string, quantity = "") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Adds an ingredient to the current meal page. */
|
/** Adds an ingredient to the current meal page. */
|
||||||
export async function addIngredient(page: Page, name: string, quantity = "") {
|
export async function addIngredient(
|
||||||
|
page: Page,
|
||||||
|
name: string,
|
||||||
|
quantity = "",
|
||||||
|
category?: string,
|
||||||
|
) {
|
||||||
await page.fill("#ingredient-name", name);
|
await page.fill("#ingredient-name", name);
|
||||||
|
if (category) {
|
||||||
|
await page.selectOption("#ingredient-category", { label: category });
|
||||||
|
}
|
||||||
if (quantity) {
|
if (quantity) {
|
||||||
await page.fill("#ingredient-quantity", quantity);
|
await page.fill("#ingredient-quantity", quantity);
|
||||||
}
|
}
|
||||||
await page.click("#add-ingredient-button");
|
await page.click("#add-ingredient-button");
|
||||||
|
// The form submit is hx-boosted (full body swap to the same URL), so wait for
|
||||||
|
// the new row to appear. This also acts as a settle point so the next action
|
||||||
|
// doesn't race the async body replacement and target a stale form.
|
||||||
await expect(page.locator(".ingredient-list").filter({ hasText: name })).toBeVisible();
|
await expect(page.locator(".ingredient-list").filter({ hasText: name })).toBeVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,3 +52,47 @@ test("the add-meal picker closes when clicking outside", async ({ page }) => {
|
|||||||
await page.mouse.click(10, 10);
|
await page.mouse.click(10, 10);
|
||||||
await expect(picker).toHaveCount(0);
|
await expect(picker).toHaveCount(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("a meal added to a list is shown in the meals panel", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createMealWithIngredients(page, "Spaghetti Bolognese", [
|
||||||
|
{ name: "Penne", quantity: "500g" },
|
||||||
|
{ name: "Tomato", quantity: "2" },
|
||||||
|
]);
|
||||||
|
await createList(page, "Weekly shop");
|
||||||
|
|
||||||
|
await page.click(".add-meal-button");
|
||||||
|
const picker = page.locator(".meal-picker-backdrop");
|
||||||
|
await picker.locator(".meal-picker-button").filter({ hasText: "Spaghetti Bolognese" }).click();
|
||||||
|
|
||||||
|
// The meal appears in the "Meals on this list" panel.
|
||||||
|
const panel = page.locator("#list-meals-panel");
|
||||||
|
await expect(panel).toBeVisible();
|
||||||
|
await expect(panel.locator(".list-meal-row").filter({ hasText: "Spaghetti Bolognese" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("removing a meal from a list removes its ingredients", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createMealWithIngredients(page, "Spaghetti Bolognese", [
|
||||||
|
{ name: "Penne", quantity: "500g" },
|
||||||
|
{ name: "Tomato", quantity: "2" },
|
||||||
|
]);
|
||||||
|
await createList(page, "Weekly shop");
|
||||||
|
|
||||||
|
await page.click(".add-meal-button");
|
||||||
|
const picker = page.locator(".meal-picker-backdrop");
|
||||||
|
await picker.locator(".meal-picker-button").filter({ hasText: "Spaghetti Bolognese" }).click();
|
||||||
|
|
||||||
|
await expect(page.locator(".item-row").filter({ hasText: "Penne" })).toBeVisible();
|
||||||
|
await expect(page.locator(".item-row").filter({ hasText: "Tomato" })).toBeVisible();
|
||||||
|
|
||||||
|
// Remove the meal from the list.
|
||||||
|
const panel = page.locator("#list-meals-panel");
|
||||||
|
const row = panel.locator(".list-meal-row").filter({ hasText: "Spaghetti Bolognese" });
|
||||||
|
await row.locator(".list-meal-remove-button").click();
|
||||||
|
|
||||||
|
// The meal's ingredients are removed from the list.
|
||||||
|
await expect(page.locator(".item-row").filter({ hasText: "Penne" })).toHaveCount(0);
|
||||||
|
await expect(page.locator(".item-row").filter({ hasText: "Tomato" })).toHaveCount(0);
|
||||||
|
await expect(row).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import { expect } from "@playwright/test";
|
||||||
|
import { test } from "../fixtures";
|
||||||
|
import { registerAndLogin, createList, addItem } from "../helpers";
|
||||||
|
|
||||||
|
test("a user can archive a list and it moves to the archive page", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createList(page, "Weekly shop");
|
||||||
|
|
||||||
|
// Archive from the list page.
|
||||||
|
await page.click('button:has-text("Archive")');
|
||||||
|
|
||||||
|
// Lands back on the lists page; the list is no longer shown.
|
||||||
|
await expect(page).toHaveURL(/\/lists/);
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Weekly shop" })).toHaveCount(0);
|
||||||
|
|
||||||
|
// The archived list is reachable from the archive page.
|
||||||
|
await page.goto("/archive");
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Weekly shop" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the lists frame links to the archive page", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createList(page, "Weekly shop");
|
||||||
|
await page.goto("/lists");
|
||||||
|
|
||||||
|
await page.click('a.archive-link');
|
||||||
|
await expect(page).toHaveURL(/\/archive/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("an archived list is read-only", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createList(page, "Weekly shop");
|
||||||
|
await addItem(page, "Apple");
|
||||||
|
await page.click('button:has-text("Archive")');
|
||||||
|
|
||||||
|
// Open the archived list directly.
|
||||||
|
await page.goto("/archive");
|
||||||
|
await page.locator(".list-card").filter({ hasText: "Weekly shop" }).click();
|
||||||
|
await expect(page).toHaveURL(/\/lists\/\d+/);
|
||||||
|
|
||||||
|
// The item is still visible.
|
||||||
|
await expect(page.locator(".item-row").filter({ hasText: "Apple" })).toBeVisible();
|
||||||
|
|
||||||
|
// No mutation UI is present.
|
||||||
|
await expect(page.locator("#add-item-form")).toHaveCount(0);
|
||||||
|
await expect(page.locator(".item-actions-button")).toHaveCount(0);
|
||||||
|
await expect(page.locator(".check-form")).toHaveCount(0);
|
||||||
|
await expect(page.locator('button:has-text("+ Add meal")')).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a user can restore an archived list and edit it again", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createList(page, "Weekly shop");
|
||||||
|
await addItem(page, "Apple");
|
||||||
|
await page.click('button:has-text("Archive")');
|
||||||
|
|
||||||
|
// Open the archived list and restore it.
|
||||||
|
await page.goto("/archive");
|
||||||
|
await page.locator(".list-card").filter({ hasText: "Weekly shop" }).click();
|
||||||
|
await page.click('button:has-text("Restore")');
|
||||||
|
|
||||||
|
// Back on the lists page, the list is active again.
|
||||||
|
await expect(page).toHaveURL(/\/lists/);
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Weekly shop" })).toBeVisible();
|
||||||
|
|
||||||
|
// The list is editable again.
|
||||||
|
await page.locator(".list-card").filter({ hasText: "Weekly shop" }).click();
|
||||||
|
await expect(page.locator("#add-item-form")).toBeVisible();
|
||||||
|
await addItem(page, "Banana");
|
||||||
|
await expect(page.locator(".item-row").filter({ hasText: "Banana" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the archive page shows the list name and created date", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createList(page, "Weekly shop");
|
||||||
|
await page.click('button:has-text("Archive")');
|
||||||
|
|
||||||
|
await page.goto("/archive");
|
||||||
|
const card = page.locator(".list-card").filter({ hasText: "Weekly shop" });
|
||||||
|
await expect(card).toBeVisible();
|
||||||
|
// The card shows a created date (e.g. "Created 7 Aug 2026").
|
||||||
|
await expect(card.locator("small")).toContainText("Created");
|
||||||
|
});
|
||||||
@@ -13,3 +13,33 @@ test("a user can log out", async ({ page }) => {
|
|||||||
await expect(page).toHaveURL(/\/login/);
|
await expect(page).toHaveURL(/\/login/);
|
||||||
await expect(page.locator("h1")).toContainText("Welcome back");
|
await expect(page.locator("h1")).toContainText("Welcome back");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("a user can change their password", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await page.goto("/account");
|
||||||
|
await page.fill("#new-password", "a-new-strong-password");
|
||||||
|
await page.fill("#confirm-password", "a-new-strong-password");
|
||||||
|
await page.click('button:has-text("Update password")');
|
||||||
|
await expect(page.locator(".alert-success")).toContainText("updated");
|
||||||
|
|
||||||
|
// The old password no longer works; the new one does.
|
||||||
|
await page.click('button:has-text("Sign out")');
|
||||||
|
await page.fill("#email", "alice@example.com");
|
||||||
|
await page.fill("#password", "a-strong-password");
|
||||||
|
await page.click('button[type="submit"]');
|
||||||
|
await expect(page.locator(".alert-error")).toContainText("incorrect");
|
||||||
|
|
||||||
|
await page.fill("#email", "alice@example.com");
|
||||||
|
await page.fill("#password", "a-new-strong-password");
|
||||||
|
await page.click('button[type="submit"]');
|
||||||
|
await expect(page).toHaveURL(/\/lists/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("changing password rejects a mismatched confirmation", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await page.goto("/account");
|
||||||
|
await page.fill("#new-password", "a-new-strong-password");
|
||||||
|
await page.fill("#confirm-password", "a-different-password");
|
||||||
|
await page.click('button:has-text("Update password")');
|
||||||
|
await expect(page.locator(".alert-error")).toContainText("do not match");
|
||||||
|
});
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ test("a user can add a category", async ({ page }) => {
|
|||||||
await registerAndLogin(page, "alice@example.com");
|
await registerAndLogin(page, "alice@example.com");
|
||||||
await createList(page, "Weekly shop");
|
await createList(page, "Weekly shop");
|
||||||
|
|
||||||
|
// Categories are managed from the main lists page.
|
||||||
|
await page.goto("/lists");
|
||||||
await page.fill("#category-name", "Bakery");
|
await page.fill("#category-name", "Bakery");
|
||||||
await page.click("#add-category-button");
|
await page.click("#add-category-button");
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
import { expect } from "@playwright/test";
|
||||||
|
import { test } from "../fixtures";
|
||||||
|
import { registerAndLogin, createMeal } from "../helpers";
|
||||||
|
|
||||||
|
test("meals are grouped under their category on the meals page", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
|
||||||
|
await createMeal(page, "Beef Stew", "", "Beef");
|
||||||
|
await createMeal(page, "Chicken Curry", "", "Chicken");
|
||||||
|
await createMeal(page, "Plain Rice", "");
|
||||||
|
|
||||||
|
await page.goto("/meals");
|
||||||
|
|
||||||
|
// Each category appears as a heading with its meals beneath it.
|
||||||
|
const beef = page.locator(".category-group").filter({ hasText: "Beef" });
|
||||||
|
await expect(beef.locator(".category-heading")).toContainText("Beef");
|
||||||
|
await expect(beef.locator(".list-card").filter({ hasText: "Beef Stew" })).toBeVisible();
|
||||||
|
|
||||||
|
const chicken = page.locator(".category-group").filter({ hasText: "Chicken" });
|
||||||
|
await expect(chicken.locator(".list-card").filter({ hasText: "Chicken Curry" })).toBeVisible();
|
||||||
|
|
||||||
|
// Uncategorized meals land in their own group.
|
||||||
|
const uncategorized = page.locator(".category-group").filter({ hasText: "Uncategorized" });
|
||||||
|
await expect(uncategorized.locator(".list-card").filter({ hasText: "Plain Rice" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a user can create a meal category", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
|
||||||
|
await page.goto("/meals");
|
||||||
|
await page.fill('form[action="/meals/categories"] input[name="name"]', "Breakfast");
|
||||||
|
await page.click('form[action="/meals/categories"] button[type="submit"]');
|
||||||
|
|
||||||
|
await expect(page).toHaveURL(/\/meals$/);
|
||||||
|
await expect(page.locator(".meal-category-name").filter({ hasText: "Breakfast" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a user can delete a meal category and its meals become uncategorized", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
|
||||||
|
// Create a custom category and a meal in it.
|
||||||
|
await page.goto("/meals");
|
||||||
|
await page.fill('form[action="/meals/categories"] input[name="name"]', "Breakfast");
|
||||||
|
await page.click('form[action="/meals/categories"] button[type="submit"]');
|
||||||
|
await expect(page).toHaveURL(/\/meals$/);
|
||||||
|
|
||||||
|
await createMeal(page, "Pancakes", "", "Breakfast");
|
||||||
|
|
||||||
|
// Delete the category.
|
||||||
|
await page.goto("/meals");
|
||||||
|
const row = page.locator(".meal-category-row").filter({ hasText: "Breakfast" });
|
||||||
|
await row.locator(".meal-category-delete").click();
|
||||||
|
await expect(page).toHaveURL(/\/meals$/);
|
||||||
|
|
||||||
|
// The category is gone and the meal is now uncategorized.
|
||||||
|
await expect(page.locator(".meal-category-name").filter({ hasText: "Breakfast" })).toHaveCount(0);
|
||||||
|
const uncategorized = page.locator(".category-group").filter({ hasText: "Uncategorized" });
|
||||||
|
await expect(uncategorized.locator(".list-card").filter({ hasText: "Pancakes" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a user can change a meal's category via the edit modal", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createMeal(page, "Beef Stew", "", "Beef");
|
||||||
|
|
||||||
|
await page.click('button:has-text("Edit")');
|
||||||
|
const dialog = page.locator("dialog#meal-edit-modal");
|
||||||
|
await expect(dialog).toBeVisible();
|
||||||
|
await dialog.locator("#meal-edit-category").selectOption({ label: "Chicken" });
|
||||||
|
await dialog.locator("#meal-edit-save").click();
|
||||||
|
|
||||||
|
await expect(page).toHaveURL(/\/meals\/\d+/);
|
||||||
|
await page.goto("/meals");
|
||||||
|
|
||||||
|
const chicken = page.locator(".category-group").filter({
|
||||||
|
has: page.locator(".category-heading", { hasText: "Chicken" }),
|
||||||
|
});
|
||||||
|
await expect(chicken.locator(".list-card").filter({ hasText: "Beef Stew" })).toBeVisible();
|
||||||
|
const beef = page.locator(".category-group").filter({
|
||||||
|
has: page.locator(".category-heading", { hasText: "Beef" }),
|
||||||
|
});
|
||||||
|
await expect(beef.locator(".list-card").filter({ hasText: "Beef Stew" })).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a meal's category is shown on its page", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createMeal(page, "Beef Stew", "", "Beef");
|
||||||
|
|
||||||
|
await expect(page.locator(".meal-category-label")).toHaveText("(Beef)");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the add-meal picker groups meals by category", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createMeal(page, "Beef Stew", "", "Beef");
|
||||||
|
await createMeal(page, "Chicken Curry", "", "Chicken");
|
||||||
|
|
||||||
|
// Go to a list to open the picker.
|
||||||
|
await page.goto("/lists");
|
||||||
|
await page.fill("#list-name", "Weekly shop");
|
||||||
|
await page.click('button:has-text("Create list")');
|
||||||
|
await expect(page).toHaveURL(/\/lists\/\d+/);
|
||||||
|
|
||||||
|
await page.click(".add-meal-button");
|
||||||
|
const picker = page.locator(".meal-picker-backdrop");
|
||||||
|
await expect(picker).toBeVisible();
|
||||||
|
|
||||||
|
const beef = picker.locator(".category-group").filter({ hasText: "Beef" });
|
||||||
|
await expect(beef.locator(".meal-picker-button").filter({ hasText: "Beef Stew" })).toBeVisible();
|
||||||
|
|
||||||
|
const chicken = picker.locator(".category-group").filter({ hasText: "Chicken" });
|
||||||
|
await expect(chicken.locator(".meal-picker-button").filter({ hasText: "Chicken Curry" })).toBeVisible();
|
||||||
|
});
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { expect } from "@playwright/test";
|
||||||
|
import { test } from "../fixtures";
|
||||||
|
import { registerAndLogin, createList, createMeal } from "../helpers";
|
||||||
|
|
||||||
|
test("the meals page filters by name as you type", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createMeal(page, "Spaghetti Bolognese", "");
|
||||||
|
await createMeal(page, "Chicken Curry", "");
|
||||||
|
await createMeal(page, "Pancakes", "");
|
||||||
|
|
||||||
|
await page.goto("/meals");
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Spaghetti Bolognese" })).toBeVisible();
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Chicken Curry" })).toBeVisible();
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Pancakes" })).toBeVisible();
|
||||||
|
|
||||||
|
// Type a query; only matching meals remain.
|
||||||
|
await page.fill("#meal-search", "chicken");
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Chicken Curry" })).toBeVisible();
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Spaghetti Bolognese" })).toHaveCount(0);
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Pancakes" })).toHaveCount(0);
|
||||||
|
|
||||||
|
// Clearing the search restores all meals.
|
||||||
|
await page.fill("#meal-search", "");
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Spaghetti Bolognese" })).toBeVisible();
|
||||||
|
await expect(page.locator(".list-card").filter({ hasText: "Pancakes" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the meals page shows an empty state when nothing matches", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createMeal(page, "Spaghetti Bolognese", "");
|
||||||
|
|
||||||
|
await page.goto("/meals");
|
||||||
|
await page.fill("#meal-search", "zzzz");
|
||||||
|
await expect(page.locator(".meal-filter-empty")).toBeVisible();
|
||||||
|
await expect(page.locator(".list-card")).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the add-meal picker filters meals as you type", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await createMeal(page, "Spaghetti Bolognese", "");
|
||||||
|
await createMeal(page, "Chicken Curry", "");
|
||||||
|
await createList(page, "Weekly shop");
|
||||||
|
|
||||||
|
await page.click(".add-meal-button");
|
||||||
|
const picker = page.locator(".meal-picker-backdrop");
|
||||||
|
await expect(picker).toBeVisible();
|
||||||
|
await expect(picker.locator(".meal-picker-button").filter({ hasText: "Spaghetti Bolognese" })).toBeVisible();
|
||||||
|
await expect(picker.locator(".meal-picker-button").filter({ hasText: "Chicken Curry" })).toBeVisible();
|
||||||
|
|
||||||
|
await picker.locator(".meal-filter").fill("curry");
|
||||||
|
await expect(picker.locator(".meal-picker-button").filter({ hasText: "Chicken Curry" })).toBeVisible();
|
||||||
|
await expect(picker.locator(".meal-picker-button").filter({ hasText: "Spaghetti Bolognese" })).toHaveCount(0);
|
||||||
|
|
||||||
|
// The search box keeps focus and the modal stays open.
|
||||||
|
await expect(picker.locator(".meal-filter")).toBeFocused();
|
||||||
|
await expect(picker).toBeVisible();
|
||||||
|
});
|
||||||
@@ -32,6 +32,7 @@ test("a user can delete a meal", async ({ page }) => {
|
|||||||
await registerAndLogin(page, "alice@example.com");
|
await registerAndLogin(page, "alice@example.com");
|
||||||
await createMeal(page, "Spaghetti Bolognese", "");
|
await createMeal(page, "Spaghetti Bolognese", "");
|
||||||
|
|
||||||
|
page.on("dialog", (dialog) => dialog.accept());
|
||||||
await page.click('button:has-text("Delete")');
|
await page.click('button:has-text("Delete")');
|
||||||
await expect(page).toHaveURL(/\/meals$/);
|
await expect(page).toHaveURL(/\/meals$/);
|
||||||
await expect(page.locator(".list-card").filter({ hasText: "Spaghetti Bolognese" })).toHaveCount(0);
|
await expect(page.locator(".list-card").filter({ hasText: "Spaghetti Bolognese" })).toHaveCount(0);
|
||||||
@@ -76,9 +77,7 @@ test("ingredients are grouped under their categories", async ({ page }) => {
|
|||||||
await createMeal(page, "Spaghetti Bolognese", "");
|
await createMeal(page, "Spaghetti Bolognese", "");
|
||||||
|
|
||||||
// Add an ingredient in the default "Produce" category.
|
// Add an ingredient in the default "Produce" category.
|
||||||
await page.fill("#ingredient-name", "Tomato");
|
await addIngredient(page, "Tomato", "", "Produce");
|
||||||
await page.selectOption("#ingredient-category", { label: "Produce" });
|
|
||||||
await page.click("#add-ingredient-button");
|
|
||||||
|
|
||||||
// Add one without a category.
|
// Add one without a category.
|
||||||
await addIngredient(page, "Penne");
|
await addIngredient(page, "Penne");
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ test("a user can register a passkey and sign in with it", async ({ page, browser
|
|||||||
await p.click('button:has-text("Sign out")');
|
await p.click('button:has-text("Sign out")');
|
||||||
await expect(p).toHaveURL(/\/login/);
|
await expect(p).toHaveURL(/\/login/);
|
||||||
|
|
||||||
// Sign in with the passkey.
|
// Sign in with the passkey without entering an email (userless sign-in).
|
||||||
await p.fill("#email", "alice@example.com");
|
|
||||||
await p.click("#passkey-login");
|
await p.click("#passkey-login");
|
||||||
await expect(p).toHaveURL(/\/lists/);
|
await expect(p).toHaveURL(/\/lists/);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
import { expect } from "@playwright/test";
|
||||||
|
import { test } from "../fixtures";
|
||||||
|
import { registerAndLogin } from "../helpers";
|
||||||
|
|
||||||
|
/** Navigates to the rewards cards page. */
|
||||||
|
async function gotoRewards(page: import("@playwright/test").Page) {
|
||||||
|
await page.goto("/rewards");
|
||||||
|
await expect(page.locator("h1")).toContainText("Rewards cards");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a rewards card and lands back on the /rewards page with it rendered.
|
||||||
|
*/
|
||||||
|
async function addCard(
|
||||||
|
page: import("@playwright/test").Page,
|
||||||
|
storeName: string,
|
||||||
|
number: string,
|
||||||
|
symbology?: string,
|
||||||
|
) {
|
||||||
|
await page.fill("#store-name", storeName);
|
||||||
|
await page.fill("#card-number", number);
|
||||||
|
if (symbology) {
|
||||||
|
await page.selectOption("#symbology", symbology);
|
||||||
|
}
|
||||||
|
await page.click('button:has-text("Add card")');
|
||||||
|
await expect(page).toHaveURL(/\/rewards$/);
|
||||||
|
const card = page.locator(".rewards-card").filter({ hasText: storeName });
|
||||||
|
await expect(card).toBeVisible();
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
|
||||||
|
test("the rewards page shows an empty state before any cards are added", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await gotoRewards(page);
|
||||||
|
await expect(page.locator(".empty-state")).toContainText("No rewards cards yet");
|
||||||
|
await expect(page.locator(".rewards-card")).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the Rewards link is available in the site navigation", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
const nav = page.locator(".site-nav");
|
||||||
|
await expect(nav.locator('a[href="/rewards"]')).toHaveText("Rewards");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a user can add a rewards card and see its barcode", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await gotoRewards(page);
|
||||||
|
|
||||||
|
const card = await addCard(page, "Kroger", "606171584511340224537");
|
||||||
|
|
||||||
|
// The card renders an inline SVG barcode and the store's card number.
|
||||||
|
await expect(card.locator(".rewards-barcode svg")).toBeVisible();
|
||||||
|
await expect(card.locator(".rewards-number")).toHaveText("606171584511340224537");
|
||||||
|
|
||||||
|
// The barcode should be included via the embedded SVG (Code 128 set B→C mix),
|
||||||
|
// not rendered client-side from scratch by an image.
|
||||||
|
const svg = card.locator(".rewards-barcode svg");
|
||||||
|
await expect(svg).toHaveAttribute("viewBox", /\d+ \d+/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a user can add a card as Code 39 and see its barcode", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await gotoRewards(page);
|
||||||
|
|
||||||
|
const card = await addCard(page, "Safeway", "ABC123", "code39");
|
||||||
|
await expect(card.locator(".rewards-barcode svg")).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("multiple rewards cards are each rendered with their own barcode", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await gotoRewards(page);
|
||||||
|
|
||||||
|
await addCard(page, "Kroger", "606171584511340224537");
|
||||||
|
await addCard(page, "Safeway", "012345678901");
|
||||||
|
|
||||||
|
await expect(page.locator(".rewards-card")).toHaveCount(2);
|
||||||
|
await expect(page.locator(".rewards-card").filter({ hasText: "Kroger" })).toBeVisible();
|
||||||
|
await expect(page.locator(".rewards-card").filter({ hasText: "Safeway" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("removing a rewards card prompts for confirmation and deletes on accept", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await gotoRewards(page);
|
||||||
|
await addCard(page, "Kroger", "606171584511340224537");
|
||||||
|
|
||||||
|
await expect(page).toHaveURL(/\/rewards$/);
|
||||||
|
await expect(page.locator(".rewards-card")).toHaveCount(1);
|
||||||
|
|
||||||
|
page.on("dialog", (dialog) => dialog.accept());
|
||||||
|
await page.click('button:has-text("Remove")');
|
||||||
|
|
||||||
|
// The card is deleted and the empty state returns.
|
||||||
|
await expect(page.locator(".rewards-card")).toHaveCount(0);
|
||||||
|
await expect(page.locator(".empty-state")).toContainText("No rewards cards yet");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("cancelling the remove confirmation keeps the rewards card", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await gotoRewards(page);
|
||||||
|
await addCard(page, "Kroger", "606171584511340224537");
|
||||||
|
|
||||||
|
await expect(page.locator(".rewards-card")).toHaveCount(1);
|
||||||
|
|
||||||
|
page.on("dialog", (dialog) => dialog.dismiss());
|
||||||
|
await page.click('button:has-text("Remove")');
|
||||||
|
|
||||||
|
// The card must remain after cancelling.
|
||||||
|
await expect(page.locator(".rewards-card")).toHaveCount(1);
|
||||||
|
await expect(page.locator(".rewards-card").filter({ hasText: "Kroger" })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a user can open a single-card scan view with only one barcode", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await gotoRewards(page);
|
||||||
|
await addCard(page, "Kroger", "606171584511340224537");
|
||||||
|
await addCard(page, "Safeway", "012345678901");
|
||||||
|
|
||||||
|
// Click the Kroger card's barcode to open its focused scan view.
|
||||||
|
await page
|
||||||
|
.locator(".rewards-card")
|
||||||
|
.filter({ hasText: "Kroger" })
|
||||||
|
.locator(".rewards-card-link")
|
||||||
|
.click();
|
||||||
|
|
||||||
|
await expect(page).toHaveURL(/\/rewards\/\d+/);
|
||||||
|
// Only one barcode is rendered on the scan page.
|
||||||
|
await expect(page.locator(".scan-barcode svg")).toHaveCount(1);
|
||||||
|
await expect(page.locator(".scan-store")).toHaveText("Kroger");
|
||||||
|
await expect(page.locator(".scan-card .rewards-number")).toHaveText(
|
||||||
|
"606171584511340224537",
|
||||||
|
);
|
||||||
|
// The wake-lock script is loaded on the scan page.
|
||||||
|
await expect(page.locator('script[src*="rewards.js"]')).toHaveCount(1);
|
||||||
|
|
||||||
|
// Back link returns to the list.
|
||||||
|
await page.click('.scan-back');
|
||||||
|
await expect(page).toHaveURL(/\/rewards$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a scan view for another user's card is not accessible", async ({ page }) => {
|
||||||
|
await registerAndLogin(page, "alice@example.com");
|
||||||
|
await gotoRewards(page);
|
||||||
|
await addCard(page, "Kroger", "606171584511340224537");
|
||||||
|
|
||||||
|
// Grab the card id from the URL of the scan view.
|
||||||
|
await page
|
||||||
|
.locator(".rewards-card-link")
|
||||||
|
.click();
|
||||||
|
const url = page.url();
|
||||||
|
const cardId = url.split("/").pop();
|
||||||
|
|
||||||
|
// Sign out and sign in as a different user.
|
||||||
|
await page.click('button:has-text("Sign out")');
|
||||||
|
await registerAndLogin(page, "bob@example.com");
|
||||||
|
|
||||||
|
// Bob cannot view Alice's card.
|
||||||
|
await page.goto(`/rewards/${cardId}`);
|
||||||
|
await expect(page.locator(".scan-barcode svg")).toHaveCount(0);
|
||||||
|
});
|
||||||
@@ -20,12 +20,25 @@ test("a list updates live for another user via websocket", async ({ page, browse
|
|||||||
// Give the websocket connections a moment to establish.
|
// Give the websocket connections a moment to establish.
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
|
|
||||||
|
// Both start with an empty list.
|
||||||
|
await expect(pageB.locator("#list-meta")).toHaveText("0 items left out of 0");
|
||||||
|
|
||||||
// User A adds an item.
|
// User A adds an item.
|
||||||
await addItem(page, "Apple", "2");
|
await addItem(page, "Apple", "2");
|
||||||
|
|
||||||
// It should appear on User B's page without any reload.
|
// It should appear on User B's page without any reload.
|
||||||
await expect(pageB.locator(".item-row").filter({ hasText: "Apple" })).toBeVisible();
|
await expect(pageB.locator(".item-row").filter({ hasText: "Apple" })).toBeVisible();
|
||||||
await expect(pageB.locator(".item-row").filter({ hasText: "Apple" }).locator(".item-qty")).toHaveText("(2)");
|
await expect(pageB.locator(".item-row").filter({ hasText: "Apple" }).locator(".item-qty")).toHaveText("(2)");
|
||||||
|
// The left/total count should also update live for User B.
|
||||||
|
await expect(pageB.locator("#list-meta")).toHaveText("1 items left out of 1");
|
||||||
|
|
||||||
|
// User A removes the item.
|
||||||
|
await page.locator(".item-actions-button").first().click();
|
||||||
|
await page.locator("[id^='item-edit-delete']").click();
|
||||||
|
|
||||||
|
// The item and the count should update live on User B's page.
|
||||||
|
await expect(pageB.locator(".item-row").filter({ hasText: "Apple" })).toHaveCount(0);
|
||||||
|
await expect(pageB.locator("#list-meta")).toHaveText("0 items left out of 0");
|
||||||
|
|
||||||
await contextB.close();
|
await contextB.close();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
CREATE TABLE users (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
email TEXT NOT NULL UNIQUE COLLATE NOCASE,
|
||||||
|
display_name TEXT NOT NULL,
|
||||||
|
password_hash TEXT NOT NULL,
|
||||||
|
user_handle BLOB NOT NULL UNIQUE,
|
||||||
|
created_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE sessions (
|
||||||
|
token_hash BLOB PRIMARY KEY,
|
||||||
|
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
csrf_token BLOB NOT NULL,
|
||||||
|
expires_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE passkeys (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
credential_id TEXT NOT NULL UNIQUE,
|
||||||
|
credential TEXT NOT NULL,
|
||||||
|
counter INTEGER NOT NULL DEFAULT 0,
|
||||||
|
created_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE lists (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
revision INTEGER NOT NULL DEFAULT 0,
|
||||||
|
created_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE categories (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT NOT NULL UNIQUE COLLATE NOCASE,
|
||||||
|
position INTEGER NOT NULL DEFAULT 0,
|
||||||
|
created_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE invitations (
|
||||||
|
token_hash BLOB PRIMARY KEY,
|
||||||
|
created_by INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
expires_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE items (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
list_id INTEGER NOT NULL REFERENCES lists(id) ON DELETE CASCADE,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
quantity TEXT NOT NULL DEFAULT '',
|
||||||
|
note TEXT NOT NULL DEFAULT '',
|
||||||
|
category_id INTEGER REFERENCES categories(id) ON DELETE SET NULL,
|
||||||
|
checked INTEGER NOT NULL DEFAULT 0,
|
||||||
|
version INTEGER NOT NULL DEFAULT 1,
|
||||||
|
position INTEGER NOT NULL DEFAULT 0,
|
||||||
|
created_at INTEGER NOT NULL,
|
||||||
|
updated_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE meals (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
description TEXT NOT NULL DEFAULT '',
|
||||||
|
created_at INTEGER NOT NULL,
|
||||||
|
updated_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE meal_ingredients (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
meal_id INTEGER NOT NULL REFERENCES meals(id) ON DELETE CASCADE,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
quantity TEXT NOT NULL DEFAULT '',
|
||||||
|
note TEXT NOT NULL DEFAULT '',
|
||||||
|
category_id INTEGER REFERENCES categories(id) ON DELETE SET NULL,
|
||||||
|
position INTEGER NOT NULL DEFAULT 0
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX items_list_idx ON items(list_id);
|
||||||
|
CREATE INDEX meal_ingredients_meal_idx ON meal_ingredients(meal_id);
|
||||||
|
CREATE INDEX sessions_user_idx ON sessions(user_id);
|
||||||
|
CREATE INDEX passkeys_user_idx ON passkeys(user_id);
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
CREATE TABLE meal_categories (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT NOT NULL UNIQUE COLLATE NOCASE,
|
||||||
|
position INTEGER NOT NULL DEFAULT 0,
|
||||||
|
created_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE meals ADD COLUMN category_id INTEGER REFERENCES meal_categories(id) ON DELETE SET NULL;
|
||||||
|
|
||||||
|
CREATE INDEX meals_category_idx ON meals(category_id);
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
CREATE TABLE list_meals (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
list_id INTEGER NOT NULL REFERENCES lists(id) ON DELETE CASCADE,
|
||||||
|
meal_id INTEGER REFERENCES meals(id) ON DELETE SET NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
created_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE items ADD COLUMN list_meal_id INTEGER REFERENCES list_meals(id) ON DELETE CASCADE;
|
||||||
|
|
||||||
|
CREATE INDEX list_meals_list_idx ON list_meals(list_id);
|
||||||
|
CREATE INDEX items_list_meal_idx ON items(list_meal_id);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE lists ADD COLUMN archived_at INTEGER;
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
CREATE TABLE rewards_cards (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
store_name TEXT NOT NULL,
|
||||||
|
number TEXT NOT NULL,
|
||||||
|
symbology TEXT NOT NULL DEFAULT 'code128',
|
||||||
|
created_at INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX rewards_cards_user_idx ON rewards_cards(user_id);
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
|
/// A single static asset: its embedded bytes and a content hash used to
|
||||||
|
/// version its URL.
|
||||||
|
pub struct StaticAsset {
|
||||||
|
pub data: &'static [u8],
|
||||||
|
pub hash: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A registry of the app's static assets, keyed by filename. Each asset's
|
||||||
|
/// content hash is computed once on first use and cached, so the versioned URL
|
||||||
|
/// changes automatically whenever the underlying file changes.
|
||||||
|
pub struct StaticAssetStore {
|
||||||
|
assets: HashMap<&'static str, StaticAsset>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StaticAssetStore {
|
||||||
|
fn new(entries: &[(&'static str, &'static [u8])]) -> Self {
|
||||||
|
let assets = entries
|
||||||
|
.iter()
|
||||||
|
.map(|(name, data)| {
|
||||||
|
let hash = content_hash(data);
|
||||||
|
(*name, StaticAsset { data, hash })
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
Self { assets }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Looks up an asset by its filename (e.g. `"style.css"`).
|
||||||
|
pub fn get(&self, name: &str) -> Option<&StaticAsset> {
|
||||||
|
self.assets.get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the versioned URL for an asset, e.g. `/static/style.css?v=<hash>`.
|
||||||
|
pub fn url(&self, name: &str) -> Option<String> {
|
||||||
|
self.assets
|
||||||
|
.get(name)
|
||||||
|
.map(|asset| format!("/static/{name}?v={}", asset.hash))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn content_hash(data: &[u8]) -> String {
|
||||||
|
let mut hasher = Sha256::new();
|
||||||
|
hasher.update(data);
|
||||||
|
hex::encode(hasher.finalize())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Constructs a `StaticAssetStore` from `name => path` pairs, embedding each
|
||||||
|
/// file's bytes at compile time via `include_bytes!`.
|
||||||
|
macro_rules! static_assets {
|
||||||
|
($($name:literal => $path:literal),* $(,)?) => {
|
||||||
|
StaticAssetStore::new(&[
|
||||||
|
$(($name, include_bytes!($path))),*
|
||||||
|
])
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The app's static assets, loaded once on first use.
|
||||||
|
pub static STORE: LazyLock<StaticAssetStore> = LazyLock::new(|| {
|
||||||
|
static_assets! {
|
||||||
|
"style.css" => "../static/style.css",
|
||||||
|
"passkey-login.js" => "../static/passkey-login.js",
|
||||||
|
"passkey-register.js" => "../static/passkey-register.js",
|
||||||
|
"password-toggle.js" => "../static/password-toggle.js",
|
||||||
|
"rewards.js" => "../static/rewards.js",
|
||||||
|
"htmx.min.js" => "../static/htmx.min.js",
|
||||||
|
"idiomorph-ext.min.js" => "../static/idiomorph-ext.min.js",
|
||||||
|
"htmx-ws.min.js" => "../static/htmx-ws.min.js",
|
||||||
|
"favicon.ico" => "../static/favicon.ico",
|
||||||
|
"favicon-32x32.png" => "../static/favicon-32x32.png",
|
||||||
|
"apple-touch-icon.png" => "../static/apple-touch-icon.png",
|
||||||
|
"logo.svg" => "../static/logo.svg",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Returns the versioned URL for a known asset, panicking if the name isn't
|
||||||
|
/// registered (a programmer error, since these are compile-time constants).
|
||||||
|
pub fn url(name: &str) -> String {
|
||||||
|
STORE
|
||||||
|
.url(name)
|
||||||
|
.unwrap_or_else(|| panic!("unknown static asset: {name}"))
|
||||||
|
}
|
||||||
@@ -19,6 +19,10 @@ pub struct User {
|
|||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub email: String,
|
pub email: String,
|
||||||
pub display_name: String,
|
pub display_name: String,
|
||||||
|
/// Opaque, random user handle used as the WebAuthn userHandle. Kept
|
||||||
|
/// high-entropy and unpredictable per the WebAuthn spec to avoid user
|
||||||
|
/// enumeration and cross-site correlation. Stored as raw bytes.
|
||||||
|
pub user_handle: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@@ -27,6 +31,9 @@ pub struct Passkey {
|
|||||||
pub user_id: i64,
|
pub user_id: i64,
|
||||||
pub credential_id: String,
|
pub credential_id: String,
|
||||||
pub credential: String,
|
pub credential: String,
|
||||||
|
/// WebAuthn sign counter, persisted for future cloned-authenticator
|
||||||
|
/// detection. Not currently read by application logic.
|
||||||
|
#[allow(dead_code)]
|
||||||
pub counter: i64,
|
pub counter: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +48,10 @@ pub struct GroceryList {
|
|||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub revision: i64,
|
pub revision: i64,
|
||||||
|
/// Unix timestamp of when the list was created.
|
||||||
|
pub created_at: i64,
|
||||||
|
/// Unix timestamp of when the list was archived; `None` when active.
|
||||||
|
pub archived_at: Option<i64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@@ -61,11 +72,18 @@ pub struct Category {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct MealCategory {
|
||||||
|
pub id: i64,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Meal {
|
pub struct Meal {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
|
pub category_id: Option<i64>,
|
||||||
pub ingredients: Vec<MealIngredient>,
|
pub ingredients: Vec<MealIngredient>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +96,36 @@ pub struct MealIngredient {
|
|||||||
pub category_id: Option<i64>,
|
pub category_id: Option<i64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct ListMeal {
|
||||||
|
pub id: i64,
|
||||||
|
/// The catalog meal this instance came from; `None` once the meal is deleted.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub meal_id: Option<i64>,
|
||||||
|
pub name: String,
|
||||||
|
/// When the meal was added to the list.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub created_at: i64,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PresenceUser {
|
pub struct PresenceUser {
|
||||||
pub user_id: i64,
|
pub user_id: i64,
|
||||||
pub display_name: String,
|
pub display_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A stored rewards-card number that can be shown as a scannable barcode.
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct RewardsCard {
|
||||||
|
pub id: i64,
|
||||||
|
/// The owner of this card.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub user_id: i64,
|
||||||
|
pub store_name: String,
|
||||||
|
pub number: String,
|
||||||
|
/// Symbology used to render the barcode (e.g. "code128", "code39").
|
||||||
|
pub symbology: String,
|
||||||
|
/// When the card was added.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub created_at: i64,
|
||||||
|
}
|
||||||
|
|||||||
+402
-50
@@ -14,29 +14,28 @@ use axum::{
|
|||||||
routing::{get, post},
|
routing::{get, post},
|
||||||
};
|
};
|
||||||
use futures_util::{SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
|
use maud::PreEscaped;
|
||||||
use serde::{Deserialize, de::DeserializeOwned};
|
use serde::{Deserialize, de::DeserializeOwned};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tower_http::trace::{DefaultMakeSpan, DefaultOnResponse, TraceLayer};
|
use tower_http::trace::{DefaultMakeSpan, DefaultOnResponse, TraceLayer};
|
||||||
use tracing::{Level, error, warn};
|
use tracing::{Level, error, warn};
|
||||||
|
|
||||||
|
use crate::assets;
|
||||||
use crate::domain::{DomainError, SessionUser};
|
use crate::domain::{DomainError, SessionUser};
|
||||||
use crate::ports::{HubEvent, RealtimeNotifier};
|
use crate::ports::{HubEvent, RealtimeNotifier};
|
||||||
use crate::services::{AuthService, InvitationService, ListService, MealService};
|
use crate::services::{
|
||||||
|
AuthService, InvitationService, ListService, MealService, RewardsCardService,
|
||||||
|
};
|
||||||
use crate::views;
|
use crate::views;
|
||||||
use crate::webauthn::WebAuthnService;
|
use crate::webauthn::WebAuthnService;
|
||||||
|
|
||||||
/// The contents of `static/`, embedded into the binary at compile time so the
|
|
||||||
/// app can be shipped as a single executable without a separate static directory.
|
|
||||||
const STYLE_CSS: &[u8] = include_bytes!("../static/style.css");
|
|
||||||
const PASSKEY_LOGIN_JS: &[u8] = include_bytes!("../static/passkey-login.js");
|
|
||||||
const PASSKEY_REGISTER_JS: &[u8] = include_bytes!("../static/passkey-register.js");
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
pub auth: Arc<AuthService>,
|
pub auth: Arc<AuthService>,
|
||||||
pub lists: Arc<ListService>,
|
pub lists: Arc<ListService>,
|
||||||
pub meals: Arc<MealService>,
|
pub meals: Arc<MealService>,
|
||||||
pub invitations: Arc<InvitationService>,
|
pub invitations: Arc<InvitationService>,
|
||||||
|
pub rewards_cards: Arc<RewardsCardService>,
|
||||||
pub webauthn: Arc<WebAuthnService>,
|
pub webauthn: Arc<WebAuthnService>,
|
||||||
pub realtime: Arc<dyn RealtimeNotifier>,
|
pub realtime: Arc<dyn RealtimeNotifier>,
|
||||||
pub cookie_secure: bool,
|
pub cookie_secure: bool,
|
||||||
@@ -51,6 +50,8 @@ pub enum AppError {
|
|||||||
BadRequest(String),
|
BadRequest(String),
|
||||||
#[error("not found")]
|
#[error("not found")]
|
||||||
NotFound,
|
NotFound,
|
||||||
|
#[error("list is archived")]
|
||||||
|
Archived,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoResponse for AppError {
|
impl IntoResponse for AppError {
|
||||||
@@ -70,6 +71,10 @@ impl IntoResponse for AppError {
|
|||||||
StatusCode::NOT_FOUND,
|
StatusCode::NOT_FOUND,
|
||||||
views::error_page("404", "That page could not be found."),
|
views::error_page("404", "That page could not be found."),
|
||||||
),
|
),
|
||||||
|
AppError::Archived => status_html_response(
|
||||||
|
StatusCode::CONFLICT,
|
||||||
|
views::error_page("409", "This list is archived and cannot be modified."),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,8 +97,12 @@ pub fn build_router(state: AppState) -> Router {
|
|||||||
"/account/passkeys/{passkey_id}/delete",
|
"/account/passkeys/{passkey_id}/delete",
|
||||||
post(delete_passkey),
|
post(delete_passkey),
|
||||||
)
|
)
|
||||||
|
.route("/account/password", post(change_password))
|
||||||
.route("/lists", get(lists_page).post(create_list))
|
.route("/lists", get(lists_page).post(create_list))
|
||||||
|
.route("/archive", get(archive_page))
|
||||||
.route("/lists/{list_id}", get(list_page))
|
.route("/lists/{list_id}", get(list_page))
|
||||||
|
.route("/lists/{list_id}/archive", post(archive_list))
|
||||||
|
.route("/lists/{list_id}/unarchive", post(unarchive_list))
|
||||||
.route("/lists/{list_id}/items", post(add_item))
|
.route("/lists/{list_id}/items", post(add_item))
|
||||||
.route("/lists/{list_id}/items/{item_id}/check", post(check_item))
|
.route("/lists/{list_id}/items/{item_id}/check", post(check_item))
|
||||||
.route("/lists/{list_id}/items/{item_id}/edit", post(edit_item))
|
.route("/lists/{list_id}/items/{item_id}/edit", post(edit_item))
|
||||||
@@ -102,6 +111,11 @@ pub fn build_router(state: AppState) -> Router {
|
|||||||
.route("/invitations", post(create_invitation))
|
.route("/invitations", post(create_invitation))
|
||||||
.route("/meals", get(meals_page).post(create_meal))
|
.route("/meals", get(meals_page).post(create_meal))
|
||||||
.route("/meals/new", get(new_meal_page))
|
.route("/meals/new", get(new_meal_page))
|
||||||
|
.route("/meals/categories", post(create_meal_category))
|
||||||
|
.route(
|
||||||
|
"/meals/categories/{category_id}/delete",
|
||||||
|
post(delete_meal_category),
|
||||||
|
)
|
||||||
.route("/meals/{meal_id}", get(meal_page))
|
.route("/meals/{meal_id}", get(meal_page))
|
||||||
.route("/meals/{meal_id}/edit", post(edit_meal))
|
.route("/meals/{meal_id}/edit", post(edit_meal))
|
||||||
.route("/meals/{meal_id}/delete", post(delete_meal))
|
.route("/meals/{meal_id}/delete", post(delete_meal))
|
||||||
@@ -115,6 +129,13 @@ pub fn build_router(state: AppState) -> Router {
|
|||||||
post(delete_ingredient),
|
post(delete_ingredient),
|
||||||
)
|
)
|
||||||
.route("/lists/{list_id}/add-meal", post(add_meal_to_list))
|
.route("/lists/{list_id}/add-meal", post(add_meal_to_list))
|
||||||
|
.route(
|
||||||
|
"/lists/{list_id}/meals/{list_meal_id}/remove",
|
||||||
|
post(remove_meal_from_list),
|
||||||
|
)
|
||||||
|
.route("/rewards", get(rewards_page).post(create_rewards_card))
|
||||||
|
.route("/rewards/{card_id}", get(rewards_scan_page))
|
||||||
|
.route("/rewards/{card_id}/delete", post(delete_rewards_card))
|
||||||
.route("/lists/{list_id}/stream", get(list_stream))
|
.route("/lists/{list_id}/stream", get(list_stream))
|
||||||
.route("/invite/{token}", get(invitation_page))
|
.route("/invite/{token}", get(invitation_page))
|
||||||
.route("/invite/{token}/accept", post(accept_invitation))
|
.route("/invite/{token}/accept", post(accept_invitation))
|
||||||
@@ -246,6 +267,14 @@ struct CategoryForm {
|
|||||||
csrf: String,
|
csrf: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct RewardsCardForm {
|
||||||
|
store_name: String,
|
||||||
|
number: String,
|
||||||
|
symbology: String,
|
||||||
|
csrf: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct PasskeyRegisterStartForm {
|
struct PasskeyRegisterStartForm {
|
||||||
csrf: String,
|
csrf: String,
|
||||||
@@ -259,11 +288,13 @@ struct PasskeyRegisterFinishForm {
|
|||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct PasskeyLoginStartForm {
|
struct PasskeyLoginStartForm {
|
||||||
|
#[serde(default)]
|
||||||
email: String,
|
email: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct PasskeyLoginFinishForm {
|
struct PasskeyLoginFinishForm {
|
||||||
|
token: String,
|
||||||
response: webauthn_rs::proto::PublicKeyCredential,
|
response: webauthn_rs::proto::PublicKeyCredential,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,11 +303,20 @@ struct DeletePasskeyForm {
|
|||||||
csrf: String,
|
csrf: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct ChangePasswordForm {
|
||||||
|
csrf: String,
|
||||||
|
new_password: String,
|
||||||
|
confirm_password: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct MealForm {
|
struct MealForm {
|
||||||
name: String,
|
name: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
description: String,
|
description: String,
|
||||||
|
#[serde(default)]
|
||||||
|
category_id: Option<String>,
|
||||||
csrf: String,
|
csrf: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,6 +341,7 @@ struct AddMealForm {
|
|||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct MealPickerQuery {
|
struct MealPickerQuery {
|
||||||
picker: Option<i64>,
|
picker: Option<i64>,
|
||||||
|
q: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn home() -> Redirect {
|
async fn home() -> Redirect {
|
||||||
@@ -308,14 +349,27 @@ async fn home() -> Redirect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Serves a file embedded in the binary from the `static/` folder.
|
/// Serves a file embedded in the binary from the `static/` folder.
|
||||||
|
///
|
||||||
|
/// Every asset is served with an immutable, long-lived cache header. Because
|
||||||
|
/// the HTML references each asset under a URL that is versioned by its content
|
||||||
|
/// hash, a changed file gets a new URL and the cache is never stale.
|
||||||
async fn static_asset(Path(path): Path<String>) -> Response {
|
async fn static_asset(Path(path): Path<String>) -> Response {
|
||||||
let (mime, data) = match path.as_str() {
|
let Some(asset) = assets::STORE.get(&path) else {
|
||||||
"style.css" => ("text/css", STYLE_CSS),
|
return StatusCode::NOT_FOUND.into_response();
|
||||||
"passkey-login.js" => ("application/javascript", PASSKEY_LOGIN_JS),
|
|
||||||
"passkey-register.js" => ("application/javascript", PASSKEY_REGISTER_JS),
|
|
||||||
_ => return StatusCode::NOT_FOUND.into_response(),
|
|
||||||
};
|
};
|
||||||
([(header::CONTENT_TYPE, mime)], data).into_response()
|
let mime = match path.rsplit('.').next() {
|
||||||
|
Some("css") => "text/css",
|
||||||
|
Some("ico") => "image/x-icon",
|
||||||
|
Some("png") => "image/png",
|
||||||
|
Some("svg") => "image/svg+xml",
|
||||||
|
_ => "application/javascript",
|
||||||
|
};
|
||||||
|
let mut response = ([(header::CONTENT_TYPE, mime)], asset.data).into_response();
|
||||||
|
response.headers_mut().insert(
|
||||||
|
header::CACHE_CONTROL,
|
||||||
|
HeaderValue::from_static("public, max-age=31536000, immutable"),
|
||||||
|
);
|
||||||
|
response
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn log_response_status(request: Request, next: Next) -> Response {
|
async fn log_response_status(request: Request, next: Next) -> Response {
|
||||||
@@ -446,9 +500,42 @@ async fn account_page(
|
|||||||
&user.session.user,
|
&user.session.user,
|
||||||
&passkeys,
|
&passkeys,
|
||||||
&user.session.csrf_token,
|
&user.session.csrf_token,
|
||||||
|
None,
|
||||||
|
false,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn change_password(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
LoggedForm(form): LoggedForm<ChangePasswordForm>,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
verify_csrf(&user, &form.csrf)?;
|
||||||
|
let passkeys = state.webauthn.list_passkeys(user.session.user.id).await?;
|
||||||
|
let render = |error: Option<&str>, success: bool| {
|
||||||
|
html_response(views::account_page(
|
||||||
|
&user.session.user,
|
||||||
|
&passkeys,
|
||||||
|
&user.session.csrf_token,
|
||||||
|
error,
|
||||||
|
success,
|
||||||
|
))
|
||||||
|
};
|
||||||
|
|
||||||
|
if form.new_password != form.confirm_password {
|
||||||
|
return Ok(render(
|
||||||
|
Some("New password and confirmation do not match."),
|
||||||
|
false,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
state
|
||||||
|
.auth
|
||||||
|
.change_password(user.session.user.id, form.new_password)
|
||||||
|
.await?;
|
||||||
|
Ok(render(None, true))
|
||||||
|
}
|
||||||
|
|
||||||
async fn passkey_register_start(
|
async fn passkey_register_start(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
user: CurrentUser,
|
user: CurrentUser,
|
||||||
@@ -480,15 +567,28 @@ async fn passkey_login_start(
|
|||||||
Json(form): Json<PasskeyLoginStartForm>,
|
Json(form): Json<PasskeyLoginStartForm>,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
let email = form.email.trim().to_lowercase();
|
let email = form.email.trim().to_lowercase();
|
||||||
let Some((user, _)) = state.auth.find_user_by_email(email).await? else {
|
let (challenge, token) = if email.is_empty() {
|
||||||
return Err(AppError::NotFound);
|
// Userless sign-in: no email needed, the authenticator selects a
|
||||||
|
// discoverable credential and returns a user handle.
|
||||||
|
state
|
||||||
|
.webauthn
|
||||||
|
.start_userless_authentication()
|
||||||
|
.await
|
||||||
|
.map_err(AppError::Database)?
|
||||||
|
} else {
|
||||||
|
let Some((user, _)) = state.auth.find_user_by_email(email).await? else {
|
||||||
|
return Err(AppError::NotFound);
|
||||||
|
};
|
||||||
|
state
|
||||||
|
.webauthn
|
||||||
|
.start_authentication(user.id)
|
||||||
|
.await
|
||||||
|
.map_err(AppError::Database)?
|
||||||
};
|
};
|
||||||
let challenge = state
|
Ok(
|
||||||
.webauthn
|
Json(serde_json::json!({ "token": token, "publicKey": challenge.public_key }))
|
||||||
.start_authentication(user.id)
|
.into_response(),
|
||||||
.await
|
)
|
||||||
.map_err(AppError::Database)?;
|
|
||||||
Ok(Json(challenge).into_response())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn passkey_login_finish(
|
async fn passkey_login_finish(
|
||||||
@@ -497,11 +597,7 @@ async fn passkey_login_finish(
|
|||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
let user_id = state
|
let user_id = state
|
||||||
.webauthn
|
.webauthn
|
||||||
.resolve_user_id_for_assertion(&form.response)
|
.finish_authentication(form.token, form.response)
|
||||||
.await?;
|
|
||||||
state
|
|
||||||
.webauthn
|
|
||||||
.finish_authentication(user_id, form.response)
|
|
||||||
.await?;
|
.await?;
|
||||||
let (session_token, _) = state.auth.create_session_for_user(user_id).await?;
|
let (session_token, _) = state.auth.create_session_for_user(user_id).await?;
|
||||||
let mut response = Redirect::to("/lists").into_response();
|
let mut response = Redirect::to("/lists").into_response();
|
||||||
@@ -528,13 +624,28 @@ async fn lists_page(
|
|||||||
user: CurrentUser,
|
user: CurrentUser,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
let lists = state.lists.list_summaries().await?;
|
let lists = state.lists.list_summaries().await?;
|
||||||
|
let archived = state.lists.list_archived_summaries().await?;
|
||||||
|
let categories = state.lists.categories().await?;
|
||||||
Ok(html_response(views::lists_page(
|
Ok(html_response(views::lists_page(
|
||||||
&user.session.user,
|
&user.session.user,
|
||||||
&lists,
|
&lists,
|
||||||
|
archived.len(),
|
||||||
|
&categories,
|
||||||
&user.session.csrf_token,
|
&user.session.csrf_token,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn archive_page(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
let archived_lists = state.lists.list_archived_summaries().await?;
|
||||||
|
Ok(html_response(views::archive_page(
|
||||||
|
&user.session.user,
|
||||||
|
&archived_lists,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
async fn create_list(
|
async fn create_list(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
user: CurrentUser,
|
user: CurrentUser,
|
||||||
@@ -559,17 +670,43 @@ async fn list_page(
|
|||||||
let access = require_list(&state, list_id).await?;
|
let access = require_list(&state, list_id).await?;
|
||||||
let items = state.lists.items(list_id).await?;
|
let items = state.lists.items(list_id).await?;
|
||||||
let categories = state.lists.categories().await?;
|
let categories = state.lists.categories().await?;
|
||||||
|
let list_meals = state.meals.list_meals_on_list(list_id).await?;
|
||||||
let presence = state.realtime.presence(list_id).await;
|
let presence = state.realtime.presence(list_id).await;
|
||||||
Ok(html_response(views::list_page(
|
Ok(html_response(views::list_page(
|
||||||
&user.session.user,
|
&user.session.user,
|
||||||
&access,
|
&access,
|
||||||
&items,
|
&items,
|
||||||
&categories,
|
&categories,
|
||||||
|
&list_meals,
|
||||||
&presence,
|
&presence,
|
||||||
&user.session.csrf_token,
|
&user.session.csrf_token,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn archive_list(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
Path(list_id): Path<i64>,
|
||||||
|
LoggedForm(form): LoggedForm<CsrfForm>,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
verify_csrf(&user, &form.csrf)?;
|
||||||
|
require_list(&state, list_id).await?;
|
||||||
|
state.lists.archive_list(list_id).await?;
|
||||||
|
Ok(Redirect::to("/lists").into_response())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn unarchive_list(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
Path(list_id): Path<i64>,
|
||||||
|
LoggedForm(form): LoggedForm<CsrfForm>,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
verify_csrf(&user, &form.csrf)?;
|
||||||
|
require_list(&state, list_id).await?;
|
||||||
|
state.lists.unarchive_list(list_id).await?;
|
||||||
|
Ok(Redirect::to("/lists").into_response())
|
||||||
|
}
|
||||||
|
|
||||||
async fn add_item(
|
async fn add_item(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
user: CurrentUser,
|
user: CurrentUser,
|
||||||
@@ -577,7 +714,7 @@ async fn add_item(
|
|||||||
LoggedForm(form): LoggedForm<ItemForm>,
|
LoggedForm(form): LoggedForm<ItemForm>,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
verify_csrf(&user, &form.csrf)?;
|
verify_csrf(&user, &form.csrf)?;
|
||||||
require_list(&state, list_id).await?;
|
require_mutable_list(&state, list_id).await?;
|
||||||
let name = form.name.trim().to_owned();
|
let name = form.name.trim().to_owned();
|
||||||
let quantity = form.quantity.trim().to_owned();
|
let quantity = form.quantity.trim().to_owned();
|
||||||
let note = form.note.trim().to_owned();
|
let note = form.note.trim().to_owned();
|
||||||
@@ -601,7 +738,7 @@ async fn check_item(
|
|||||||
LoggedForm(form): LoggedForm<CheckForm>,
|
LoggedForm(form): LoggedForm<CheckForm>,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
verify_csrf(&user, &form.csrf)?;
|
verify_csrf(&user, &form.csrf)?;
|
||||||
require_list(&state, list_id).await?;
|
require_mutable_list(&state, list_id).await?;
|
||||||
let checked = match form.checked.as_str() {
|
let checked = match form.checked.as_str() {
|
||||||
"1" | "true" => true,
|
"1" | "true" => true,
|
||||||
"0" | "false" => false,
|
"0" | "false" => false,
|
||||||
@@ -621,7 +758,7 @@ async fn edit_item(
|
|||||||
LoggedForm(form): LoggedForm<ItemForm>,
|
LoggedForm(form): LoggedForm<ItemForm>,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
verify_csrf(&user, &form.csrf)?;
|
verify_csrf(&user, &form.csrf)?;
|
||||||
require_list(&state, list_id).await?;
|
require_mutable_list(&state, list_id).await?;
|
||||||
let name = form.name.trim().to_owned();
|
let name = form.name.trim().to_owned();
|
||||||
if name.is_empty() || name.chars().count() > 120 {
|
if name.is_empty() || name.chars().count() > 120 {
|
||||||
return Err(AppError::BadRequest(
|
return Err(AppError::BadRequest(
|
||||||
@@ -649,7 +786,7 @@ async fn delete_item(
|
|||||||
LoggedForm(form): LoggedForm<CsrfForm>,
|
LoggedForm(form): LoggedForm<CsrfForm>,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
verify_csrf(&user, &form.csrf)?;
|
verify_csrf(&user, &form.csrf)?;
|
||||||
require_list(&state, list_id).await?;
|
require_mutable_list(&state, list_id).await?;
|
||||||
state.lists.delete_item(list_id, item_id).await?;
|
state.lists.delete_item(list_id, item_id).await?;
|
||||||
list_fragment_response(&state, &user, list_id).await
|
list_fragment_response(&state, &user, list_id).await
|
||||||
}
|
}
|
||||||
@@ -670,26 +807,178 @@ async fn create_category(
|
|||||||
Ok(Redirect::to("/lists").into_response())
|
Ok(Redirect::to("/lists").into_response())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn create_meal_category(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
LoggedForm(form): LoggedForm<CategoryForm>,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
verify_csrf(&user, &form.csrf)?;
|
||||||
|
let name = form.name.trim().to_owned();
|
||||||
|
if name.is_empty() || name.chars().count() > 60 {
|
||||||
|
return Err(AppError::BadRequest(
|
||||||
|
"Category names must be between 1 and 60 characters.".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
state.meals.create_meal_category(name).await?;
|
||||||
|
Ok(Redirect::to("/meals").into_response())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn delete_meal_category(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
Path(category_id): Path<i64>,
|
||||||
|
LoggedForm(form): LoggedForm<CsrfForm>,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
verify_csrf(&user, &form.csrf)?;
|
||||||
|
state.meals.delete_meal_category(category_id).await?;
|
||||||
|
Ok(Redirect::to("/meals").into_response())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn rewards_page(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
let cards = state.rewards_cards.list_cards(user.session.user.id).await?;
|
||||||
|
Ok(html_response(views::rewards_page(
|
||||||
|
&user.session.user,
|
||||||
|
&cards,
|
||||||
|
&user.session.csrf_token,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn rewards_scan_page(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
Path(card_id): Path<i64>,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
let card = state
|
||||||
|
.rewards_cards
|
||||||
|
.get_card(user.session.user.id, card_id)
|
||||||
|
.await?
|
||||||
|
.ok_or(AppError::NotFound)?;
|
||||||
|
Ok(html_response(views::rewards_scan_page(
|
||||||
|
&user.session.user,
|
||||||
|
&card,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn create_rewards_card(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
LoggedForm(form): LoggedForm<RewardsCardForm>,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
verify_csrf(&user, &form.csrf)?;
|
||||||
|
let store_name = form.store_name.trim().to_owned();
|
||||||
|
let number = form.number.trim().to_owned();
|
||||||
|
let symbology = normalize_symbology(&form.symbology);
|
||||||
|
if store_name.is_empty() || store_name.chars().count() > 60 {
|
||||||
|
return Err(AppError::BadRequest(
|
||||||
|
"Store names must be between 1 and 60 characters.".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if number.is_empty() || number.chars().count() > 80 {
|
||||||
|
return Err(AppError::BadRequest(
|
||||||
|
"Card numbers must be between 1 and 80 characters.".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
state
|
||||||
|
.rewards_cards
|
||||||
|
.create_card(user.session.user.id, store_name, number, symbology)
|
||||||
|
.await?;
|
||||||
|
Ok(Redirect::to("/rewards").into_response())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn delete_rewards_card(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
Path(card_id): Path<i64>,
|
||||||
|
LoggedForm(form): LoggedForm<CsrfForm>,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
verify_csrf(&user, &form.csrf)?;
|
||||||
|
state
|
||||||
|
.rewards_cards
|
||||||
|
.delete_card(user.session.user.id, card_id)
|
||||||
|
.await?;
|
||||||
|
Ok(Redirect::to("/rewards").into_response())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Normalizes a submitted symbology value to a known barcode type, falling
|
||||||
|
/// back to Code 128 for unknown or empty values.
|
||||||
|
fn normalize_symbology(value: &str) -> String {
|
||||||
|
match value.trim().to_ascii_lowercase().as_str() {
|
||||||
|
"code39" => "code39".to_owned(),
|
||||||
|
_ => "code128".to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn meals_page(
|
async fn meals_page(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
user: CurrentUser,
|
user: CurrentUser,
|
||||||
Query(query): Query<MealPickerQuery>,
|
Query(query): Query<MealPickerQuery>,
|
||||||
|
headers: HeaderMap,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
let meals = state.meals.list_meals().await?;
|
let q = query.q.clone().unwrap_or_default();
|
||||||
|
let meals = state.meals.list_meals(&q).await?;
|
||||||
|
let meal_categories = state.meals.list_meal_categories().await?;
|
||||||
|
let is_htmx = headers
|
||||||
|
.get("hx-request")
|
||||||
|
.and_then(|value| value.to_str().ok())
|
||||||
|
.is_some_and(|value| value == "true");
|
||||||
|
// A boosted navigation (e.g. the category form's POST redirect) also sends
|
||||||
|
// `HX-Request: true`, but must render the full page, not just the results
|
||||||
|
// fragment. Only a live search (an `hx-get` on the filter box) swaps the
|
||||||
|
// fragment. htmx marks boosted requests with `HX-Boosted: true`.
|
||||||
|
let is_boosted = headers
|
||||||
|
.get("hx-boosted")
|
||||||
|
.and_then(|value| value.to_str().ok())
|
||||||
|
.is_some_and(|value| value == "true");
|
||||||
if let Some(list_id) = query.picker {
|
if let Some(list_id) = query.picker {
|
||||||
return Ok(html_response(views::meal_picker(
|
if query.q.is_some() {
|
||||||
|
// Live search inside the picker: swap only the grouped rows, keeping
|
||||||
|
// the modal and search box focused. The initial picker load has no
|
||||||
|
// `q`, so it falls through to the full modal below.
|
||||||
|
return Ok(html_response(views::meal_picker_results(
|
||||||
|
&meals,
|
||||||
|
&meal_categories,
|
||||||
|
list_id,
|
||||||
|
&user.session.csrf_token,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
let picker = views::meal_picker(
|
||||||
&meals,
|
&meals,
|
||||||
|
&meal_categories,
|
||||||
list_id,
|
list_id,
|
||||||
&user.session.csrf_token,
|
&user.session.csrf_token,
|
||||||
|
&q,
|
||||||
|
);
|
||||||
|
return Ok(html_response(picker));
|
||||||
|
}
|
||||||
|
if is_htmx && !is_boosted {
|
||||||
|
// Live search on the meals page: swap only the grouped results.
|
||||||
|
return Ok(html_response(views::meal_results(
|
||||||
|
&meals,
|
||||||
|
&meal_categories,
|
||||||
|
&q,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
Ok(html_response(views::meals_page(&user.session.user, &meals)))
|
Ok(html_response(views::meals_page(
|
||||||
|
&user.session.user,
|
||||||
|
&meals,
|
||||||
|
&meal_categories,
|
||||||
|
&user.session.csrf_token,
|
||||||
|
&q,
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn new_meal_page(user: CurrentUser) -> Result<Response, AppError> {
|
async fn new_meal_page(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
let meal_categories = state.meals.list_meal_categories().await?;
|
||||||
Ok(html_response(views::meal_form_page(
|
Ok(html_response(views::meal_form_page(
|
||||||
&user.session.user,
|
&user.session.user,
|
||||||
None,
|
None,
|
||||||
|
&meal_categories,
|
||||||
&user.session.csrf_token,
|
&user.session.csrf_token,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
@@ -708,7 +997,11 @@ async fn create_meal(
|
|||||||
}
|
}
|
||||||
let meal = state
|
let meal = state
|
||||||
.meals
|
.meals
|
||||||
.create_meal(name, form.description.trim().to_owned())
|
.create_meal(
|
||||||
|
name,
|
||||||
|
form.description.trim().to_owned(),
|
||||||
|
parse_category_id(form.category_id),
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Redirect::to(&format!("/meals/{}", meal.id)).into_response())
|
Ok(Redirect::to(&format!("/meals/{}", meal.id)).into_response())
|
||||||
}
|
}
|
||||||
@@ -724,10 +1017,12 @@ async fn meal_page(
|
|||||||
.await?
|
.await?
|
||||||
.ok_or(AppError::NotFound)?;
|
.ok_or(AppError::NotFound)?;
|
||||||
let categories = state.lists.categories().await?;
|
let categories = state.lists.categories().await?;
|
||||||
|
let meal_categories = state.meals.list_meal_categories().await?;
|
||||||
Ok(html_response(views::meal_page(
|
Ok(html_response(views::meal_page(
|
||||||
&user.session.user,
|
&user.session.user,
|
||||||
&meal,
|
&meal,
|
||||||
&categories,
|
&categories,
|
||||||
|
&meal_categories,
|
||||||
&user.session.csrf_token,
|
&user.session.csrf_token,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
@@ -747,7 +1042,12 @@ async fn edit_meal(
|
|||||||
}
|
}
|
||||||
state
|
state
|
||||||
.meals
|
.meals
|
||||||
.update_meal(meal_id, name, form.description.trim().to_owned())
|
.update_meal(
|
||||||
|
meal_id,
|
||||||
|
name,
|
||||||
|
form.description.trim().to_owned(),
|
||||||
|
parse_category_id(form.category_id),
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Redirect::to(&format!("/meals/{meal_id}")).into_response())
|
Ok(Redirect::to(&format!("/meals/{meal_id}")).into_response())
|
||||||
}
|
}
|
||||||
@@ -837,11 +1137,26 @@ async fn add_meal_to_list(
|
|||||||
LoggedForm(form): LoggedForm<AddMealForm>,
|
LoggedForm(form): LoggedForm<AddMealForm>,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
verify_csrf(&user, &form.csrf)?;
|
verify_csrf(&user, &form.csrf)?;
|
||||||
require_list(&state, list_id).await?;
|
require_mutable_list(&state, list_id).await?;
|
||||||
state.meals.add_meal_to_list(form.meal_id, list_id).await?;
|
state.meals.add_meal_to_list(form.meal_id, list_id).await?;
|
||||||
list_fragment_response(&state, &user, list_id).await
|
list_fragment_response(&state, &user, list_id).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn remove_meal_from_list(
|
||||||
|
State(state): State<AppState>,
|
||||||
|
user: CurrentUser,
|
||||||
|
Path((list_id, list_meal_id)): Path<(i64, i64)>,
|
||||||
|
LoggedForm(form): LoggedForm<CsrfForm>,
|
||||||
|
) -> Result<Response, AppError> {
|
||||||
|
verify_csrf(&user, &form.csrf)?;
|
||||||
|
require_mutable_list(&state, list_id).await?;
|
||||||
|
state
|
||||||
|
.meals
|
||||||
|
.remove_meal_from_list(list_id, list_meal_id)
|
||||||
|
.await?;
|
||||||
|
list_fragment_response(&state, &user, list_id).await
|
||||||
|
}
|
||||||
|
|
||||||
async fn create_invitation(
|
async fn create_invitation(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
user: CurrentUser,
|
user: CurrentUser,
|
||||||
@@ -1006,11 +1321,16 @@ async fn websocket_snapshot(
|
|||||||
let access = require_list(state, list_id).await?;
|
let access = require_list(state, list_id).await?;
|
||||||
let items = state.lists.items(list_id).await?;
|
let items = state.lists.items(list_id).await?;
|
||||||
let categories = state.lists.categories().await?;
|
let categories = state.lists.categories().await?;
|
||||||
Ok(
|
let list_meals = state.meals.list_meals_on_list(list_id).await?;
|
||||||
views::live_list_fragments(&access, &items, &categories, &user.session.csrf_token)
|
Ok(views::live_list_fragments(
|
||||||
.into_string()
|
&access,
|
||||||
+ &views::presence_panel(presence, true).into_string(),
|
&items,
|
||||||
|
&categories,
|
||||||
|
&list_meals,
|
||||||
|
&user.session.csrf_token,
|
||||||
)
|
)
|
||||||
|
.into_string()
|
||||||
|
+ &views::presence_panel(presence, true).into_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn websocket_list_update(
|
async fn websocket_list_update(
|
||||||
@@ -1021,10 +1341,15 @@ async fn websocket_list_update(
|
|||||||
let access = require_list(state, list_id).await?;
|
let access = require_list(state, list_id).await?;
|
||||||
let items = state.lists.items(list_id).await?;
|
let items = state.lists.items(list_id).await?;
|
||||||
let categories = state.lists.categories().await?;
|
let categories = state.lists.categories().await?;
|
||||||
Ok(
|
let list_meals = state.meals.list_meals_on_list(list_id).await?;
|
||||||
views::live_list_fragments(&access, &items, &categories, &user.session.csrf_token)
|
Ok(views::live_list_fragments(
|
||||||
.into_string(),
|
&access,
|
||||||
|
&items,
|
||||||
|
&categories,
|
||||||
|
&list_meals,
|
||||||
|
&user.session.csrf_token,
|
||||||
)
|
)
|
||||||
|
.into_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn list_fragment_response(
|
async fn list_fragment_response(
|
||||||
@@ -1035,12 +1360,26 @@ async fn list_fragment_response(
|
|||||||
let access = require_list(state, list_id).await?;
|
let access = require_list(state, list_id).await?;
|
||||||
let items = state.lists.items(list_id).await?;
|
let items = state.lists.items(list_id).await?;
|
||||||
let categories = state.lists.categories().await?;
|
let categories = state.lists.categories().await?;
|
||||||
Ok(html_response(views::list_items_fragment(
|
let list_meals = state.meals.list_meals_on_list(list_id).await?;
|
||||||
&access,
|
let editable = access.archived_at.is_none();
|
||||||
&items,
|
Ok(html_response(PreEscaped(
|
||||||
&categories,
|
views::list_items_fragment(
|
||||||
&user.session.csrf_token,
|
&access,
|
||||||
false,
|
&items,
|
||||||
|
&categories,
|
||||||
|
&user.session.csrf_token,
|
||||||
|
false,
|
||||||
|
editable,
|
||||||
|
)
|
||||||
|
.into_string()
|
||||||
|
+ &views::list_meals_panel(
|
||||||
|
&list_meals,
|
||||||
|
list_id,
|
||||||
|
&user.session.csrf_token,
|
||||||
|
true,
|
||||||
|
editable,
|
||||||
|
)
|
||||||
|
.into_string(),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1055,6 +1394,19 @@ async fn require_list(
|
|||||||
.ok_or(AppError::NotFound)
|
.ok_or(AppError::NotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Like [`require_list`], but also rejects archived lists so they stay
|
||||||
|
/// immutable until restored.
|
||||||
|
async fn require_mutable_list(
|
||||||
|
state: &AppState,
|
||||||
|
list_id: i64,
|
||||||
|
) -> Result<crate::domain::GroceryList, AppError> {
|
||||||
|
let list = require_list(state, list_id).await?;
|
||||||
|
if list.archived_at.is_some() {
|
||||||
|
return Err(AppError::Archived);
|
||||||
|
}
|
||||||
|
Ok(list)
|
||||||
|
}
|
||||||
|
|
||||||
async fn optional_user(
|
async fn optional_user(
|
||||||
state: &AppState,
|
state: &AppState,
|
||||||
headers: &HeaderMap,
|
headers: &HeaderMap,
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ impl RealtimeNotifier for InMemoryHub {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let connection_id = crate::security::new_secret();
|
let connection_id = hex::encode(crate::security::new_secret());
|
||||||
let already_present = room
|
let already_present = room
|
||||||
.connections
|
.connections
|
||||||
.values()
|
.values()
|
||||||
|
|||||||
+34
-7
@@ -1,3 +1,4 @@
|
|||||||
|
mod assets;
|
||||||
mod domain;
|
mod domain;
|
||||||
mod http;
|
mod http;
|
||||||
mod hub;
|
mod hub;
|
||||||
@@ -19,16 +20,20 @@ use tracing::{info, warn};
|
|||||||
use crate::http::{AppState, build_router};
|
use crate::http::{AppState, build_router};
|
||||||
use crate::hub::InMemoryHub;
|
use crate::hub::InMemoryHub;
|
||||||
use crate::ports::{
|
use crate::ports::{
|
||||||
CategoryRepository, InvitationRepository, ItemRepository, ListRepository,
|
CategoryRepository, InvitationRepository, ItemRepository, ListMealRepository, ListRepository,
|
||||||
MealIngredientRepository, MealRepository, PasskeyRepository, PasswordHasher, RealtimeNotifier,
|
MealCategoryRepository, MealIngredientRepository, MealRepository, PasskeyRepository,
|
||||||
SessionRepository, TokenGenerator, UserRepository,
|
PasswordHasher, RealtimeNotifier, RewardsCardRepository, SessionRepository, TokenGenerator,
|
||||||
|
UserRepository,
|
||||||
};
|
};
|
||||||
use crate::security::{Argon2PasswordHasher, RandomTokenGenerator};
|
use crate::security::{Argon2PasswordHasher, RandomTokenGenerator};
|
||||||
use crate::services::{AuthService, InvitationService, ListService, MealService, RegistrationMode};
|
use crate::services::{
|
||||||
|
AuthService, InvitationService, ListService, MealService, RegistrationMode, RewardsCardService,
|
||||||
|
};
|
||||||
use crate::sqlite::{
|
use crate::sqlite::{
|
||||||
SqliteCategoryRepository, SqliteDatabase, SqliteInvitationRepository, SqliteItemRepository,
|
SqliteCategoryRepository, SqliteDatabase, SqliteInvitationRepository, SqliteItemRepository,
|
||||||
SqliteListRepository, SqliteMealIngredientRepository, SqliteMealRepository,
|
SqliteListMealRepository, SqliteListRepository, SqliteMealCategoryRepository,
|
||||||
SqlitePasskeyRepository, SqliteSessionRepository, SqliteUserRepository,
|
SqliteMealIngredientRepository, SqliteMealRepository, SqlitePasskeyRepository,
|
||||||
|
SqliteRewardsCardRepository, SqliteSessionRepository, SqliteUserRepository,
|
||||||
};
|
};
|
||||||
use crate::webauthn::{AppWebauthnConfig, WebAuthnService};
|
use crate::webauthn::{AppWebauthnConfig, WebAuthnService};
|
||||||
|
|
||||||
@@ -41,6 +46,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
let database_path = env::var("DATABASE_PATH").unwrap_or_else(|_| "sustenance.db".into());
|
let database_path = env::var("DATABASE_PATH").unwrap_or_else(|_| "sustenance.db".into());
|
||||||
|
let database_in_memory = env::var("DATABASE_IN_MEMORY")
|
||||||
|
.map(|value| value == "1" || value.eq_ignore_ascii_case("true"))
|
||||||
|
.unwrap_or(false);
|
||||||
let bind_address = env::var("BIND_ADDRESS").unwrap_or_else(|_| "127.0.0.1:3000".into());
|
let bind_address = env::var("BIND_ADDRESS").unwrap_or_else(|_| "127.0.0.1:3000".into());
|
||||||
// For loopback hosts, advertise `localhost` so WebAuthn works locally (browsers
|
// For loopback hosts, advertise `localhost` so WebAuthn works locally (browsers
|
||||||
// reject IP addresses as RP IDs). Access the app via http://localhost:PORT.
|
// reject IP addresses as RP IDs). Access the app via http://localhost:PORT.
|
||||||
@@ -68,17 +76,24 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Build the adapters (ports) and wire them into application services.
|
// Build the adapters (ports) and wire them into application services.
|
||||||
let db = SqliteDatabase::open(&database_path).await?;
|
let db = if database_in_memory {
|
||||||
|
SqliteDatabase::open_in_memory().await?
|
||||||
|
} else {
|
||||||
|
SqliteDatabase::open(&database_path).await?
|
||||||
|
};
|
||||||
let users: Arc<dyn UserRepository> = Arc::new(SqliteUserRepository);
|
let users: Arc<dyn UserRepository> = Arc::new(SqliteUserRepository);
|
||||||
let sessions: Arc<dyn SessionRepository> = Arc::new(SqliteSessionRepository);
|
let sessions: Arc<dyn SessionRepository> = Arc::new(SqliteSessionRepository);
|
||||||
let lists: Arc<dyn ListRepository> = Arc::new(SqliteListRepository);
|
let lists: Arc<dyn ListRepository> = Arc::new(SqliteListRepository);
|
||||||
let categories: Arc<dyn CategoryRepository> = Arc::new(SqliteCategoryRepository);
|
let categories: Arc<dyn CategoryRepository> = Arc::new(SqliteCategoryRepository);
|
||||||
let items: Arc<dyn ItemRepository> = Arc::new(SqliteItemRepository);
|
let items: Arc<dyn ItemRepository> = Arc::new(SqliteItemRepository);
|
||||||
|
let list_meals: Arc<dyn ListMealRepository> = Arc::new(SqliteListMealRepository);
|
||||||
let meals: Arc<dyn MealRepository> = Arc::new(SqliteMealRepository);
|
let meals: Arc<dyn MealRepository> = Arc::new(SqliteMealRepository);
|
||||||
let meal_ingredients: Arc<dyn MealIngredientRepository> =
|
let meal_ingredients: Arc<dyn MealIngredientRepository> =
|
||||||
Arc::new(SqliteMealIngredientRepository);
|
Arc::new(SqliteMealIngredientRepository);
|
||||||
|
let meal_categories: Arc<dyn MealCategoryRepository> = Arc::new(SqliteMealCategoryRepository);
|
||||||
let invitations: Arc<dyn InvitationRepository> = Arc::new(SqliteInvitationRepository);
|
let invitations: Arc<dyn InvitationRepository> = Arc::new(SqliteInvitationRepository);
|
||||||
let passkeys: Arc<dyn PasskeyRepository> = Arc::new(SqlitePasskeyRepository);
|
let passkeys: Arc<dyn PasskeyRepository> = Arc::new(SqlitePasskeyRepository);
|
||||||
|
let rewards_cards: Arc<dyn RewardsCardRepository> = Arc::new(SqliteRewardsCardRepository);
|
||||||
let hasher: Arc<dyn PasswordHasher> = Arc::new(Argon2PasswordHasher);
|
let hasher: Arc<dyn PasswordHasher> = Arc::new(Argon2PasswordHasher);
|
||||||
let tokens: Arc<dyn TokenGenerator> = Arc::new(RandomTokenGenerator);
|
let tokens: Arc<dyn TokenGenerator> = Arc::new(RandomTokenGenerator);
|
||||||
let realtime: Arc<dyn RealtimeNotifier> = Arc::new(InMemoryHub::default());
|
let realtime: Arc<dyn RealtimeNotifier> = Arc::new(InMemoryHub::default());
|
||||||
@@ -103,12 +118,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
Arc::clone(&invitations),
|
Arc::clone(&invitations),
|
||||||
Arc::clone(&tokens),
|
Arc::clone(&tokens),
|
||||||
));
|
));
|
||||||
|
let rewards_cards_service = Arc::new(RewardsCardService::new(
|
||||||
|
db.clone(),
|
||||||
|
Arc::clone(&rewards_cards),
|
||||||
|
));
|
||||||
let meals_service = Arc::new(MealService::new(
|
let meals_service = Arc::new(MealService::new(
|
||||||
db.clone(),
|
db.clone(),
|
||||||
Arc::clone(&meals),
|
Arc::clone(&meals),
|
||||||
Arc::clone(&meal_ingredients),
|
Arc::clone(&meal_ingredients),
|
||||||
|
Arc::clone(&meal_categories),
|
||||||
Arc::clone(&lists),
|
Arc::clone(&lists),
|
||||||
Arc::clone(&items),
|
Arc::clone(&items),
|
||||||
|
Arc::clone(&list_meals),
|
||||||
Arc::clone(&realtime),
|
Arc::clone(&realtime),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -132,6 +153,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let webauthn_service = Arc::new(WebAuthnService::new(
|
let webauthn_service = Arc::new(WebAuthnService::new(
|
||||||
db.clone(),
|
db.clone(),
|
||||||
AppWebauthnConfig::new(rp_id, rp_name, origin),
|
AppWebauthnConfig::new(rp_id, rp_name, origin),
|
||||||
|
Arc::clone(&users),
|
||||||
Arc::clone(&passkeys),
|
Arc::clone(&passkeys),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -143,6 +165,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
lists: lists_service,
|
lists: lists_service,
|
||||||
meals: meals_service,
|
meals: meals_service,
|
||||||
invitations: invitations_service,
|
invitations: invitations_service,
|
||||||
|
rewards_cards: rewards_cards_service,
|
||||||
webauthn: webauthn_service,
|
webauthn: webauthn_service,
|
||||||
realtime,
|
realtime,
|
||||||
cookie_secure,
|
cookie_secure,
|
||||||
@@ -157,6 +180,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.with_graceful_shutdown(shutdown_signal())
|
.with_graceful_shutdown(shutdown_signal())
|
||||||
.await?;
|
.await?;
|
||||||
info!("shutdown complete; closing database");
|
info!("shutdown complete; closing database");
|
||||||
|
// Explicitly close the pool so SQLite can checkpoint and remove the
|
||||||
|
// WAL/SHM sidecar files. Without this, the pool's background close task
|
||||||
|
// races with process exit and the sidecars can be left behind.
|
||||||
|
db.close().await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+96
-3
@@ -2,8 +2,8 @@ use async_trait::async_trait;
|
|||||||
use sqlx::SqliteConnection;
|
use sqlx::SqliteConnection;
|
||||||
|
|
||||||
use crate::domain::{
|
use crate::domain::{
|
||||||
Category, DomainResult, GroceryList, Item, Meal, MealIngredient, Passkey, PresenceUser,
|
Category, DomainResult, GroceryList, Item, ListMeal, Meal, MealCategory, MealIngredient,
|
||||||
SessionUser, User,
|
Passkey, PresenceUser, RewardsCard, SessionUser, User,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Repositories take `&mut SqliteConnection` (which a `Transaction` derefs to),
|
/// Repositories take `&mut SqliteConnection` (which a `Transaction` derefs to),
|
||||||
@@ -24,6 +24,17 @@ pub trait UserRepository: Send + Sync {
|
|||||||
txn: &mut SqliteConnection,
|
txn: &mut SqliteConnection,
|
||||||
email: String,
|
email: String,
|
||||||
) -> DomainResult<Option<(User, String)>>;
|
) -> DomainResult<Option<(User, String)>>;
|
||||||
|
async fn find_user_by_handle(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
user_handle: Vec<u8>,
|
||||||
|
) -> DomainResult<Option<User>>;
|
||||||
|
async fn update_password_hash(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
user_id: i64,
|
||||||
|
password_hash: String,
|
||||||
|
) -> DomainResult<()>;
|
||||||
async fn has_users(&self, txn: &mut SqliteConnection) -> DomainResult<bool>;
|
async fn has_users(&self, txn: &mut SqliteConnection) -> DomainResult<bool>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +88,10 @@ pub trait SessionRepository: Send + Sync {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait ListRepository: Send + Sync {
|
pub trait ListRepository: Send + Sync {
|
||||||
async fn list_summaries(&self, txn: &mut SqliteConnection) -> DomainResult<Vec<GroceryList>>;
|
async fn list_summaries(&self, txn: &mut SqliteConnection) -> DomainResult<Vec<GroceryList>>;
|
||||||
|
async fn list_archived_summaries(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
) -> DomainResult<Vec<GroceryList>>;
|
||||||
async fn create_list(
|
async fn create_list(
|
||||||
&self,
|
&self,
|
||||||
txn: &mut SqliteConnection,
|
txn: &mut SqliteConnection,
|
||||||
@@ -87,6 +102,12 @@ pub trait ListRepository: Send + Sync {
|
|||||||
txn: &mut SqliteConnection,
|
txn: &mut SqliteConnection,
|
||||||
list_id: i64,
|
list_id: i64,
|
||||||
) -> DomainResult<Option<GroceryList>>;
|
) -> DomainResult<Option<GroceryList>>;
|
||||||
|
async fn set_archived(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
list_id: i64,
|
||||||
|
archived: bool,
|
||||||
|
) -> DomainResult<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@@ -102,6 +123,9 @@ pub struct NewItem {
|
|||||||
pub quantity: String,
|
pub quantity: String,
|
||||||
pub note: String,
|
pub note: String,
|
||||||
pub category_id: Option<i64>,
|
pub category_id: Option<i64>,
|
||||||
|
/// When set, links this item to the `list_meals` row it came from, so the
|
||||||
|
/// item is removed together with that meal instance.
|
||||||
|
pub list_meal_id: Option<i64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@@ -147,6 +171,28 @@ pub trait ItemRepository: Send + Sync {
|
|||||||
) -> DomainResult<i64>;
|
) -> DomainResult<i64>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
pub trait ListMealRepository: Send + Sync {
|
||||||
|
async fn list_meals(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
list_id: i64,
|
||||||
|
) -> DomainResult<Vec<ListMeal>>;
|
||||||
|
async fn add_meal(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
list_id: i64,
|
||||||
|
meal_id: i64,
|
||||||
|
name: String,
|
||||||
|
) -> DomainResult<i64>;
|
||||||
|
async fn remove_meal(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
list_id: i64,
|
||||||
|
list_meal_id: i64,
|
||||||
|
) -> DomainResult<i64>;
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait InvitationRepository: Send + Sync {
|
pub trait InvitationRepository: Send + Sync {
|
||||||
async fn create_invitation(
|
async fn create_invitation(
|
||||||
@@ -163,6 +209,21 @@ pub trait InvitationRepository: Send + Sync {
|
|||||||
) -> DomainResult<()>;
|
) -> DomainResult<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
pub trait MealCategoryRepository: Send + Sync {
|
||||||
|
async fn meal_categories(&self, txn: &mut SqliteConnection) -> DomainResult<Vec<MealCategory>>;
|
||||||
|
async fn create_meal_category(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
name: String,
|
||||||
|
) -> DomainResult<i64>;
|
||||||
|
async fn delete_meal_category(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
category_id: i64,
|
||||||
|
) -> DomainResult<()>;
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait MealRepository: Send + Sync {
|
pub trait MealRepository: Send + Sync {
|
||||||
async fn create_meal(
|
async fn create_meal(
|
||||||
@@ -170,19 +231,21 @@ pub trait MealRepository: Send + Sync {
|
|||||||
txn: &mut SqliteConnection,
|
txn: &mut SqliteConnection,
|
||||||
name: String,
|
name: String,
|
||||||
description: String,
|
description: String,
|
||||||
|
category_id: Option<i64>,
|
||||||
) -> DomainResult<Meal>;
|
) -> DomainResult<Meal>;
|
||||||
async fn get_meal(
|
async fn get_meal(
|
||||||
&self,
|
&self,
|
||||||
txn: &mut SqliteConnection,
|
txn: &mut SqliteConnection,
|
||||||
meal_id: i64,
|
meal_id: i64,
|
||||||
) -> DomainResult<Option<Meal>>;
|
) -> DomainResult<Option<Meal>>;
|
||||||
async fn list_meals(&self, txn: &mut SqliteConnection) -> DomainResult<Vec<Meal>>;
|
async fn list_meals(&self, txn: &mut SqliteConnection, query: &str) -> DomainResult<Vec<Meal>>;
|
||||||
async fn update_meal(
|
async fn update_meal(
|
||||||
&self,
|
&self,
|
||||||
txn: &mut SqliteConnection,
|
txn: &mut SqliteConnection,
|
||||||
meal_id: i64,
|
meal_id: i64,
|
||||||
name: String,
|
name: String,
|
||||||
description: String,
|
description: String,
|
||||||
|
category_id: Option<i64>,
|
||||||
) -> DomainResult<()>;
|
) -> DomainResult<()>;
|
||||||
async fn delete_meal(&self, txn: &mut SqliteConnection, meal_id: i64) -> DomainResult<()>;
|
async fn delete_meal(&self, txn: &mut SqliteConnection, meal_id: i64) -> DomainResult<()>;
|
||||||
}
|
}
|
||||||
@@ -251,3 +314,33 @@ pub enum HubEvent {
|
|||||||
ListChanged { list_id: i64, revision: i64 },
|
ListChanged { list_id: i64, revision: i64 },
|
||||||
PresenceChanged { list_id: i64 },
|
PresenceChanged { list_id: i64 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stores and retrieves a user's rewards cards.
|
||||||
|
#[async_trait]
|
||||||
|
pub trait RewardsCardRepository: Send + Sync {
|
||||||
|
async fn list_cards(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
user_id: i64,
|
||||||
|
) -> DomainResult<Vec<RewardsCard>>;
|
||||||
|
async fn get_card(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
user_id: i64,
|
||||||
|
card_id: i64,
|
||||||
|
) -> DomainResult<Option<RewardsCard>>;
|
||||||
|
async fn create_card(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
user_id: i64,
|
||||||
|
store_name: String,
|
||||||
|
number: String,
|
||||||
|
symbology: String,
|
||||||
|
) -> DomainResult<RewardsCard>;
|
||||||
|
async fn delete_card(
|
||||||
|
&self,
|
||||||
|
txn: &mut SqliteConnection,
|
||||||
|
user_id: i64,
|
||||||
|
card_id: i64,
|
||||||
|
) -> DomainResult<()>;
|
||||||
|
}
|
||||||
|
|||||||
+5
-3
@@ -37,12 +37,14 @@ pub struct RandomTokenGenerator;
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl TokenGenerator for RandomTokenGenerator {
|
impl TokenGenerator for RandomTokenGenerator {
|
||||||
fn generate(&self) -> String {
|
fn generate(&self) -> String {
|
||||||
new_secret()
|
hex::encode(new_secret())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_secret() -> String {
|
/// Generates 32 cryptographically random bytes. Callers that need a
|
||||||
|
/// client-facing string should hex-encode the result.
|
||||||
|
pub fn new_secret() -> Vec<u8> {
|
||||||
let mut bytes = [0_u8; 32];
|
let mut bytes = [0_u8; 32];
|
||||||
OsRng.fill_bytes(&mut bytes);
|
OsRng.fill_bytes(&mut bytes);
|
||||||
hex::encode(bytes)
|
bytes.to_vec()
|
||||||
}
|
}
|
||||||
|
|||||||
+178
-10
@@ -1,10 +1,13 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::domain::{DomainError, DomainResult, GroceryList, Item, Meal, SessionUser, User};
|
use crate::domain::{
|
||||||
|
DomainError, DomainResult, GroceryList, Item, ListMeal, Meal, MealCategory, RewardsCard,
|
||||||
|
SessionUser, User,
|
||||||
|
};
|
||||||
use crate::ports::{
|
use crate::ports::{
|
||||||
CategoryRepository, InvitationRepository, ItemRepository, ListRepository,
|
CategoryRepository, InvitationRepository, ItemRepository, ListMealRepository, ListRepository,
|
||||||
MealIngredientRepository, MealRepository, NewItem, PasswordHasher, RealtimeNotifier,
|
MealCategoryRepository, MealIngredientRepository, MealRepository, NewItem, PasswordHasher,
|
||||||
SessionRepository, TokenGenerator, UserRepository,
|
RealtimeNotifier, RewardsCardRepository, SessionRepository, TokenGenerator, UserRepository,
|
||||||
};
|
};
|
||||||
use crate::sqlite::SqliteDatabase;
|
use crate::sqlite::SqliteDatabase;
|
||||||
|
|
||||||
@@ -147,6 +150,22 @@ impl AuthService {
|
|||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Replaces the user's password hash with a freshly hashed new password.
|
||||||
|
/// No current-password check is performed because the account page is
|
||||||
|
/// already authenticated and this app has no email capabilities.
|
||||||
|
pub async fn change_password(&self, user_id: i64, new_password: String) -> DomainResult<()> {
|
||||||
|
let users = Arc::clone(&self.users);
|
||||||
|
let hasher = Arc::clone(&self.hasher);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| {
|
||||||
|
Box::pin(async move {
|
||||||
|
let new_hash = hasher.hash(&new_password)?;
|
||||||
|
users.update_password_hash(txn, user_id, new_hash).await
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ListService {
|
pub struct ListService {
|
||||||
@@ -181,6 +200,13 @@ impl ListService {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn list_archived_summaries(&self) -> DomainResult<Vec<GroceryList>> {
|
||||||
|
let lists = Arc::clone(&self.lists);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| Box::pin(async move { lists.list_archived_summaries(txn).await }))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn create_list(&self, name: String) -> DomainResult<GroceryList> {
|
pub async fn create_list(&self, name: String) -> DomainResult<GroceryList> {
|
||||||
let lists = Arc::clone(&self.lists);
|
let lists = Arc::clone(&self.lists);
|
||||||
self.db
|
self.db
|
||||||
@@ -195,6 +221,20 @@ impl ListService {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn archive_list(&self, list_id: i64) -> DomainResult<()> {
|
||||||
|
let lists = Arc::clone(&self.lists);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| Box::pin(async move { lists.set_archived(txn, list_id, true).await }))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn unarchive_list(&self, list_id: i64) -> DomainResult<()> {
|
||||||
|
let lists = Arc::clone(&self.lists);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| Box::pin(async move { lists.set_archived(txn, list_id, false).await }))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn items(&self, list_id: i64) -> DomainResult<Vec<Item>> {
|
pub async fn items(&self, list_id: i64) -> DomainResult<Vec<Item>> {
|
||||||
let items = Arc::clone(&self.items);
|
let items = Arc::clone(&self.items);
|
||||||
self.db
|
self.db
|
||||||
@@ -297,8 +337,10 @@ pub struct MealService {
|
|||||||
db: SqliteDatabase,
|
db: SqliteDatabase,
|
||||||
meals: Arc<dyn MealRepository>,
|
meals: Arc<dyn MealRepository>,
|
||||||
ingredients: Arc<dyn MealIngredientRepository>,
|
ingredients: Arc<dyn MealIngredientRepository>,
|
||||||
|
meal_categories: Arc<dyn MealCategoryRepository>,
|
||||||
lists: Arc<dyn ListRepository>,
|
lists: Arc<dyn ListRepository>,
|
||||||
items: Arc<dyn ItemRepository>,
|
items: Arc<dyn ItemRepository>,
|
||||||
|
list_meals: Arc<dyn ListMealRepository>,
|
||||||
realtime: Arc<dyn RealtimeNotifier>,
|
realtime: Arc<dyn RealtimeNotifier>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,25 +349,36 @@ impl MealService {
|
|||||||
db: SqliteDatabase,
|
db: SqliteDatabase,
|
||||||
meals: Arc<dyn MealRepository>,
|
meals: Arc<dyn MealRepository>,
|
||||||
ingredients: Arc<dyn MealIngredientRepository>,
|
ingredients: Arc<dyn MealIngredientRepository>,
|
||||||
|
meal_categories: Arc<dyn MealCategoryRepository>,
|
||||||
lists: Arc<dyn ListRepository>,
|
lists: Arc<dyn ListRepository>,
|
||||||
items: Arc<dyn ItemRepository>,
|
items: Arc<dyn ItemRepository>,
|
||||||
|
list_meals: Arc<dyn ListMealRepository>,
|
||||||
realtime: Arc<dyn RealtimeNotifier>,
|
realtime: Arc<dyn RealtimeNotifier>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
db,
|
db,
|
||||||
meals,
|
meals,
|
||||||
ingredients,
|
ingredients,
|
||||||
|
meal_categories,
|
||||||
lists,
|
lists,
|
||||||
items,
|
items,
|
||||||
|
list_meals,
|
||||||
realtime,
|
realtime,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_meal(&self, name: String, description: String) -> DomainResult<Meal> {
|
pub async fn create_meal(
|
||||||
|
&self,
|
||||||
|
name: String,
|
||||||
|
description: String,
|
||||||
|
category_id: Option<i64>,
|
||||||
|
) -> DomainResult<Meal> {
|
||||||
let meals = Arc::clone(&self.meals);
|
let meals = Arc::clone(&self.meals);
|
||||||
self.db
|
self.db
|
||||||
.run(move |txn| {
|
.run(move |txn| {
|
||||||
Box::pin(async move { meals.create_meal(txn, name, description).await })
|
Box::pin(
|
||||||
|
async move { meals.create_meal(txn, name, description, category_id).await },
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
@@ -337,10 +390,11 @@ impl MealService {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_meals(&self) -> DomainResult<Vec<Meal>> {
|
pub async fn list_meals(&self, query: &str) -> DomainResult<Vec<Meal>> {
|
||||||
let meals = Arc::clone(&self.meals);
|
let meals = Arc::clone(&self.meals);
|
||||||
|
let query = query.to_owned();
|
||||||
self.db
|
self.db
|
||||||
.run(move |txn| Box::pin(async move { meals.list_meals(txn).await }))
|
.run(move |txn| Box::pin(async move { meals.list_meals(txn, &query).await }))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,11 +403,43 @@ impl MealService {
|
|||||||
meal_id: i64,
|
meal_id: i64,
|
||||||
name: String,
|
name: String,
|
||||||
description: String,
|
description: String,
|
||||||
|
category_id: Option<i64>,
|
||||||
) -> DomainResult<()> {
|
) -> DomainResult<()> {
|
||||||
let meals = Arc::clone(&self.meals);
|
let meals = Arc::clone(&self.meals);
|
||||||
self.db
|
self.db
|
||||||
.run(move |txn| {
|
.run(move |txn| {
|
||||||
Box::pin(async move { meals.update_meal(txn, meal_id, name, description).await })
|
Box::pin(async move {
|
||||||
|
meals
|
||||||
|
.update_meal(txn, meal_id, name, description, category_id)
|
||||||
|
.await
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn list_meal_categories(&self) -> DomainResult<Vec<MealCategory>> {
|
||||||
|
let meal_categories = Arc::clone(&self.meal_categories);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| Box::pin(async move { meal_categories.meal_categories(txn).await }))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create_meal_category(&self, name: String) -> DomainResult<i64> {
|
||||||
|
let meal_categories = Arc::clone(&self.meal_categories);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| {
|
||||||
|
Box::pin(async move { meal_categories.create_meal_category(txn, name).await })
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete_meal_category(&self, category_id: i64) -> DomainResult<()> {
|
||||||
|
let meal_categories = Arc::clone(&self.meal_categories);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| {
|
||||||
|
Box::pin(
|
||||||
|
async move { meal_categories.delete_meal_category(txn, category_id).await },
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
@@ -428,11 +514,12 @@ impl MealService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Expands a meal's ingredients into items on a list in one unit of work,
|
/// Expands a meal's ingredients into items on a list in one unit of work,
|
||||||
/// bumping the list revision exactly once.
|
/// recording the meal on the list and bumping the list revision exactly once.
|
||||||
pub async fn add_meal_to_list(&self, meal_id: i64, list_id: i64) -> DomainResult<i64> {
|
pub async fn add_meal_to_list(&self, meal_id: i64, list_id: i64) -> DomainResult<i64> {
|
||||||
let meals = Arc::clone(&self.meals);
|
let meals = Arc::clone(&self.meals);
|
||||||
let lists = Arc::clone(&self.lists);
|
let lists = Arc::clone(&self.lists);
|
||||||
let items = Arc::clone(&self.items);
|
let items = Arc::clone(&self.items);
|
||||||
|
let list_meals = Arc::clone(&self.list_meals);
|
||||||
let revision = self
|
let revision = self
|
||||||
.db
|
.db
|
||||||
.run(move |txn| {
|
.run(move |txn| {
|
||||||
@@ -444,6 +531,9 @@ impl MealService {
|
|||||||
if lists.get_list(txn, list_id).await?.is_none() {
|
if lists.get_list(txn, list_id).await?.is_none() {
|
||||||
return Err(DomainError::NotFound);
|
return Err(DomainError::NotFound);
|
||||||
}
|
}
|
||||||
|
let list_meal_id = list_meals
|
||||||
|
.add_meal(txn, list_id, meal.id, meal.name.clone())
|
||||||
|
.await?;
|
||||||
let new_items = meal
|
let new_items = meal
|
||||||
.ingredients
|
.ingredients
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -452,6 +542,7 @@ impl MealService {
|
|||||||
quantity: ingredient.quantity,
|
quantity: ingredient.quantity,
|
||||||
note: ingredient.note,
|
note: ingredient.note,
|
||||||
category_id: ingredient.category_id,
|
category_id: ingredient.category_id,
|
||||||
|
list_meal_id: Some(list_meal_id),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
items.add_items_bulk(txn, list_id, new_items).await
|
items.add_items_bulk(txn, list_id, new_items).await
|
||||||
@@ -461,6 +552,32 @@ impl MealService {
|
|||||||
self.realtime.publish_list_changed(list_id, revision).await;
|
self.realtime.publish_list_changed(list_id, revision).await;
|
||||||
Ok(revision)
|
Ok(revision)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Lists the meals that have been added to a list, most recent first.
|
||||||
|
pub async fn list_meals_on_list(&self, list_id: i64) -> DomainResult<Vec<ListMeal>> {
|
||||||
|
let list_meals = Arc::clone(&self.list_meals);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| Box::pin(async move { list_meals.list_meals(txn, list_id).await }))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes a meal instance from a list, deleting the items that came from it
|
||||||
|
/// and bumping the list revision exactly once.
|
||||||
|
pub async fn remove_meal_from_list(
|
||||||
|
&self,
|
||||||
|
list_id: i64,
|
||||||
|
list_meal_id: i64,
|
||||||
|
) -> DomainResult<i64> {
|
||||||
|
let list_meals = Arc::clone(&self.list_meals);
|
||||||
|
let revision = self
|
||||||
|
.db
|
||||||
|
.run(move |txn| {
|
||||||
|
Box::pin(async move { list_meals.remove_meal(txn, list_id, list_meal_id).await })
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
self.realtime.publish_list_changed(list_id, revision).await;
|
||||||
|
Ok(revision)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InvitationService {
|
pub struct InvitationService {
|
||||||
@@ -513,3 +630,54 @@ impl InvitationService {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct RewardsCardService {
|
||||||
|
db: SqliteDatabase,
|
||||||
|
cards: Arc<dyn RewardsCardRepository>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RewardsCardService {
|
||||||
|
pub fn new(db: SqliteDatabase, cards: Arc<dyn RewardsCardRepository>) -> Self {
|
||||||
|
Self { db, cards }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn list_cards(&self, user_id: i64) -> DomainResult<Vec<RewardsCard>> {
|
||||||
|
let cards = Arc::clone(&self.cards);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| Box::pin(async move { cards.list_cards(txn, user_id).await }))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_card(&self, user_id: i64, card_id: i64) -> DomainResult<Option<RewardsCard>> {
|
||||||
|
let cards = Arc::clone(&self.cards);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| Box::pin(async move { cards.get_card(txn, user_id, card_id).await }))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn create_card(
|
||||||
|
&self,
|
||||||
|
user_id: i64,
|
||||||
|
store_name: String,
|
||||||
|
number: String,
|
||||||
|
symbology: String,
|
||||||
|
) -> DomainResult<RewardsCard> {
|
||||||
|
let cards = Arc::clone(&self.cards);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| {
|
||||||
|
Box::pin(async move {
|
||||||
|
cards
|
||||||
|
.create_card(txn, user_id, store_name, number, symbology)
|
||||||
|
.await
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete_card(&self, user_id: i64, card_id: i64) -> DomainResult<()> {
|
||||||
|
let cards = Arc::clone(&self.cards);
|
||||||
|
self.db
|
||||||
|
.run(move |txn| Box::pin(async move { cards.delete_card(txn, user_id, card_id).await }))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+1014
-126
File diff suppressed because it is too large
Load Diff
+804
-145
File diff suppressed because it is too large
Load Diff
+125
-56
@@ -7,12 +7,13 @@ use webauthn_rs::{
|
|||||||
error::WebauthnError as WanError,
|
error::WebauthnError as WanError,
|
||||||
proto::{
|
proto::{
|
||||||
CreationChallengeResponse, Credential, PublicKeyCredential, RegisterPublicKeyCredential,
|
CreationChallengeResponse, Credential, PublicKeyCredential, RegisterPublicKeyCredential,
|
||||||
RequestChallengeResponse,
|
RequestChallengeResponse, UserVerificationPolicy,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::domain::{DomainError, DomainResult, Passkey as DbPasskey, User};
|
use crate::domain::{DomainError, DomainResult, Passkey as DbPasskey, User};
|
||||||
use crate::ports::PasskeyRepository;
|
use crate::ports::{PasskeyRepository, UserRepository};
|
||||||
|
use crate::security::new_secret;
|
||||||
use crate::sqlite::SqliteDatabase;
|
use crate::sqlite::SqliteDatabase;
|
||||||
|
|
||||||
/// Site-specific WebAuthn configuration, derived from env vars.
|
/// Site-specific WebAuthn configuration, derived from env vars.
|
||||||
@@ -20,6 +21,7 @@ pub struct AppWebauthnConfig {
|
|||||||
rp_id: String,
|
rp_id: String,
|
||||||
rp_name: String,
|
rp_name: String,
|
||||||
origin: url::Url,
|
origin: url::Url,
|
||||||
|
require_resident_key: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppWebauthnConfig {
|
impl AppWebauthnConfig {
|
||||||
@@ -28,6 +30,10 @@ impl AppWebauthnConfig {
|
|||||||
rp_id,
|
rp_id,
|
||||||
rp_name,
|
rp_name,
|
||||||
origin,
|
origin,
|
||||||
|
// Resident (discoverable) keys let users sign in without typing an
|
||||||
|
// email, because the authenticator can select the credential on its
|
||||||
|
// own and return the user handle.
|
||||||
|
require_resident_key: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,18 +48,24 @@ impl WebauthnConfig for AppWebauthnConfig {
|
|||||||
fn get_relying_party_id(&self) -> &str {
|
fn get_relying_party_id(&self) -> &str {
|
||||||
&self.rp_id
|
&self.rp_id
|
||||||
}
|
}
|
||||||
|
fn get_require_resident_key(&self) -> bool {
|
||||||
|
self.require_resident_key
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A single-use, in-memory challenge store keyed by user id.
|
/// A single-use, in-memory challenge store. Registrations are keyed by user id;
|
||||||
|
/// authentications are keyed by a random token so that userless (discoverable)
|
||||||
|
/// ceremonies can be correlated back to the finish request.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ChallengeStore {
|
struct ChallengeStore {
|
||||||
registrations: HashMap<i64, RegistrationState>,
|
registrations: HashMap<i64, RegistrationState>,
|
||||||
authentications: HashMap<i64, AuthenticationState>,
|
authentications: HashMap<String, AuthenticationState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WebAuthnService {
|
pub struct WebAuthnService {
|
||||||
db: SqliteDatabase,
|
db: SqliteDatabase,
|
||||||
webauthn: Webauthn<AppWebauthnConfig>,
|
webauthn: Webauthn<AppWebauthnConfig>,
|
||||||
|
users: Arc<dyn UserRepository>,
|
||||||
passkeys: Arc<dyn PasskeyRepository>,
|
passkeys: Arc<dyn PasskeyRepository>,
|
||||||
challenges: Mutex<ChallengeStore>,
|
challenges: Mutex<ChallengeStore>,
|
||||||
}
|
}
|
||||||
@@ -62,12 +74,14 @@ impl WebAuthnService {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
db: SqliteDatabase,
|
db: SqliteDatabase,
|
||||||
config: AppWebauthnConfig,
|
config: AppWebauthnConfig,
|
||||||
|
users: Arc<dyn UserRepository>,
|
||||||
passkeys: Arc<dyn PasskeyRepository>,
|
passkeys: Arc<dyn PasskeyRepository>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let webauthn = Webauthn::new(config);
|
let webauthn = Webauthn::new(config);
|
||||||
Self {
|
Self {
|
||||||
db,
|
db,
|
||||||
webauthn,
|
webauthn,
|
||||||
|
users,
|
||||||
passkeys,
|
passkeys,
|
||||||
challenges: Mutex::new(ChallengeStore::default()),
|
challenges: Mutex::new(ChallengeStore::default()),
|
||||||
}
|
}
|
||||||
@@ -75,9 +89,19 @@ impl WebAuthnService {
|
|||||||
|
|
||||||
/// Start a passkey registration ceremony for an authenticated user.
|
/// Start a passkey registration ceremony for an authenticated user.
|
||||||
pub fn start_registration(&self, user: &User) -> DomainResult<CreationChallengeResponse> {
|
pub fn start_registration(&self, user: &User) -> DomainResult<CreationChallengeResponse> {
|
||||||
|
// Use the user's opaque, random user handle as the WebAuthn userHandle
|
||||||
|
// so that userless (discoverable) sign-in can resolve the owning user
|
||||||
|
// from the assertion's userHandle without exposing the numeric id.
|
||||||
let (challenge, state) = self
|
let (challenge, state) = self
|
||||||
.webauthn
|
.webauthn
|
||||||
.generate_challenge_register(&user.display_name, true)
|
.generate_challenge_register_options(
|
||||||
|
user.user_handle.clone(),
|
||||||
|
user.email.clone(),
|
||||||
|
user.display_name.clone(),
|
||||||
|
None,
|
||||||
|
Some(UserVerificationPolicy::Required),
|
||||||
|
None,
|
||||||
|
)
|
||||||
.map_err(webauthn_error)?;
|
.map_err(webauthn_error)?;
|
||||||
self.challenges
|
self.challenges
|
||||||
.lock()
|
.lock()
|
||||||
@@ -127,11 +151,12 @@ impl WebAuthnService {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start a passkey authentication ceremony for a user.
|
/// Start a passkey authentication ceremony for a user identified by email.
|
||||||
|
/// Returns the challenge and a token used to correlate the finish request.
|
||||||
pub async fn start_authentication(
|
pub async fn start_authentication(
|
||||||
&self,
|
&self,
|
||||||
user_id: i64,
|
user_id: i64,
|
||||||
) -> DomainResult<RequestChallengeResponse> {
|
) -> DomainResult<(RequestChallengeResponse, String)> {
|
||||||
let passkeys = Arc::clone(&self.passkeys);
|
let passkeys = Arc::clone(&self.passkeys);
|
||||||
let db = self.db.clone();
|
let db = self.db.clone();
|
||||||
let credentials: Vec<Credential> = db
|
let credentials: Vec<Credential> = db
|
||||||
@@ -156,28 +181,91 @@ impl WebAuthnService {
|
|||||||
.webauthn
|
.webauthn
|
||||||
.generate_challenge_authenticate(credentials)
|
.generate_challenge_authenticate(credentials)
|
||||||
.map_err(webauthn_error)?;
|
.map_err(webauthn_error)?;
|
||||||
|
let token = hex::encode(new_secret());
|
||||||
self.challenges
|
self.challenges
|
||||||
.lock()
|
.lock()
|
||||||
.map_err(|_| DomainError::Database("challenge lock poisoned".into()))?
|
.map_err(|_| DomainError::Database("challenge lock poisoned".into()))?
|
||||||
.authentications
|
.authentications
|
||||||
.insert(user_id, state);
|
.insert(token.clone(), state);
|
||||||
Ok(challenge)
|
Ok((challenge, token))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finish a passkey authentication ceremony.
|
/// Start a userless passkey authentication ceremony. No email is required:
|
||||||
|
/// the authenticator selects a discoverable credential and returns a user
|
||||||
|
/// handle that we resolve to the owning user on finish.
|
||||||
|
pub async fn start_userless_authentication(
|
||||||
|
&self,
|
||||||
|
) -> DomainResult<(RequestChallengeResponse, String)> {
|
||||||
|
let (challenge, mut state) = self
|
||||||
|
.webauthn
|
||||||
|
.generate_challenge_authenticate_options(vec![], None)
|
||||||
|
.map_err(webauthn_error)?;
|
||||||
|
// With no allowCredentials the browser will offer any discoverable
|
||||||
|
// credential for this RP; the credential set is populated from the
|
||||||
|
// user handle once the assertion is received.
|
||||||
|
state.set_allowed_credentials(vec![]);
|
||||||
|
let token = hex::encode(new_secret());
|
||||||
|
self.challenges
|
||||||
|
.lock()
|
||||||
|
.map_err(|_| DomainError::Database("challenge lock poisoned".into()))?
|
||||||
|
.authentications
|
||||||
|
.insert(token.clone(), state);
|
||||||
|
Ok((challenge, token))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Finish a passkey authentication ceremony, resolving the owning user from
|
||||||
|
/// the credential id (and, for userless ceremonies, the user handle).
|
||||||
pub async fn finish_authentication(
|
pub async fn finish_authentication(
|
||||||
&self,
|
&self,
|
||||||
user_id: i64,
|
token: String,
|
||||||
response: PublicKeyCredential,
|
response: PublicKeyCredential,
|
||||||
) -> DomainResult<()> {
|
) -> DomainResult<i64> {
|
||||||
let state = self
|
let mut state = self
|
||||||
.challenges
|
.challenges
|
||||||
.lock()
|
.lock()
|
||||||
.map_err(|_| DomainError::Database("challenge lock poisoned".into()))?
|
.map_err(|_| DomainError::Database("challenge lock poisoned".into()))?
|
||||||
.authentications
|
.authentications
|
||||||
.remove(&user_id)
|
.remove(&token)
|
||||||
.ok_or(DomainError::NotFound)?;
|
.ok_or(DomainError::NotFound)?;
|
||||||
|
|
||||||
|
// For userless ceremonies the assertion carries a user handle that
|
||||||
|
// identifies the user; load that user's credentials so the signature
|
||||||
|
// can be verified against the correct key.
|
||||||
|
if let Some(user_handle) = response.get_user_handle() {
|
||||||
|
let handle = user_handle.to_vec();
|
||||||
|
let users = Arc::clone(&self.users);
|
||||||
|
let db = self.db.clone();
|
||||||
|
let user_id = db
|
||||||
|
.run(move |txn| {
|
||||||
|
let users = users.clone();
|
||||||
|
Box::pin(async move {
|
||||||
|
let user = users
|
||||||
|
.find_user_by_handle(txn, handle)
|
||||||
|
.await?
|
||||||
|
.ok_or(DomainError::NotFound)?;
|
||||||
|
Ok(user.id)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
let passkeys = Arc::clone(&self.passkeys);
|
||||||
|
let credentials: Vec<Credential> = db
|
||||||
|
.run(move |txn| {
|
||||||
|
let passkeys = passkeys.clone();
|
||||||
|
Box::pin(async move {
|
||||||
|
let rows = passkeys.list_for_user(txn, user_id).await?;
|
||||||
|
let mut creds = Vec::new();
|
||||||
|
for row in rows {
|
||||||
|
let cred: Credential = serde_json::from_str(&row.credential)
|
||||||
|
.map_err(|e| DomainError::Database(e.to_string()))?;
|
||||||
|
creds.push(cred);
|
||||||
|
}
|
||||||
|
Ok(creds)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
state.set_allowed_credentials(credentials);
|
||||||
|
}
|
||||||
|
|
||||||
let (cred_id, auth_data) = self
|
let (cred_id, auth_data) = self
|
||||||
.webauthn
|
.webauthn
|
||||||
.authenticate_credential(&response, &state)
|
.authenticate_credential(&response, &state)
|
||||||
@@ -189,28 +277,30 @@ impl WebAuthnService {
|
|||||||
let passkeys = Arc::clone(&self.passkeys);
|
let passkeys = Arc::clone(&self.passkeys);
|
||||||
let db = self.db.clone();
|
let db = self.db.clone();
|
||||||
let credential_id_b64 = base64_url(cred_id);
|
let credential_id_b64 = base64_url(cred_id);
|
||||||
db.run(move |txn| {
|
let user_id = db
|
||||||
let passkeys = passkeys.clone();
|
.run(move |txn| {
|
||||||
Box::pin(async move {
|
let passkeys = passkeys.clone();
|
||||||
let stored = passkeys
|
Box::pin(async move {
|
||||||
.find_by_credential_id(txn, credential_id_b64)
|
let stored = passkeys
|
||||||
.await?
|
.find_by_credential_id(txn, credential_id_b64)
|
||||||
.ok_or(DomainError::NotFound)?;
|
.await?
|
||||||
let mut cred: Credential = serde_json::from_str(&stored.credential)
|
.ok_or(DomainError::NotFound)?;
|
||||||
.map_err(|e| DomainError::Database(e.to_string()))?;
|
let mut cred: Credential = serde_json::from_str(&stored.credential)
|
||||||
cred.counter = auth_data.counter;
|
.map_err(|e| DomainError::Database(e.to_string()))?;
|
||||||
let serialized = serde_json::to_string(&cred)
|
cred.counter = auth_data.counter;
|
||||||
.map_err(|e| DomainError::Database(e.to_string()))?;
|
let serialized = serde_json::to_string(&cred)
|
||||||
sqlx::query("UPDATE passkeys SET credential = ?1 WHERE id = ?2")
|
.map_err(|e| DomainError::Database(e.to_string()))?;
|
||||||
.bind(&serialized)
|
sqlx::query("UPDATE passkeys SET credential = ?1 WHERE id = ?2")
|
||||||
.bind(stored.id)
|
.bind(&serialized)
|
||||||
.execute(&mut *txn)
|
.bind(stored.id)
|
||||||
.await
|
.execute(&mut *txn)
|
||||||
.map_err(db_error)?;
|
.await
|
||||||
Ok(())
|
.map_err(db_error)?;
|
||||||
|
Ok(stored.user_id)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
.await?;
|
||||||
.await
|
Ok(user_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List the passkeys registered to a user.
|
/// List the passkeys registered to a user.
|
||||||
@@ -234,27 +324,6 @@ impl WebAuthnService {
|
|||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resolve the user id that owns the credential in an assertion response.
|
|
||||||
pub async fn resolve_user_id_for_assertion(
|
|
||||||
&self,
|
|
||||||
response: &PublicKeyCredential,
|
|
||||||
) -> DomainResult<i64> {
|
|
||||||
let passkeys = Arc::clone(&self.passkeys);
|
|
||||||
let db = self.db.clone();
|
|
||||||
let credential_id_b64 = base64_url(&response.raw_id.0);
|
|
||||||
db.run(move |txn| {
|
|
||||||
let passkeys = passkeys.clone();
|
|
||||||
Box::pin(async move {
|
|
||||||
let stored = passkeys
|
|
||||||
.find_by_credential_id(txn, credential_id_b64)
|
|
||||||
.await?
|
|
||||||
.ok_or(DomainError::NotFound)?;
|
|
||||||
Ok(stored.user_id)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base64_url(bytes: &[u8]) -> String {
|
fn base64_url(bytes: &[u8]) -> String {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 832 B |
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
+143
@@ -0,0 +1,143 @@
|
|||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 64 64"
|
||||||
|
role="img"
|
||||||
|
aria-labelledby="title"
|
||||||
|
>
|
||||||
|
<title id="title">Sustenance grocery bag with produce</title>
|
||||||
|
|
||||||
|
<!-- Background -->
|
||||||
|
<rect width="64" height="64" rx="12" fill="#286247"/>
|
||||||
|
|
||||||
|
<!-- Back of the paper bag -->
|
||||||
|
<path
|
||||||
|
d="
|
||||||
|
M7 27
|
||||||
|
L16 22
|
||||||
|
L24 26
|
||||||
|
L32 22
|
||||||
|
L40 25
|
||||||
|
L49 21
|
||||||
|
L57 25
|
||||||
|
L47 31
|
||||||
|
L39 28
|
||||||
|
L31 32
|
||||||
|
L23 27
|
||||||
|
L16 31
|
||||||
|
Z
|
||||||
|
"
|
||||||
|
fill="#F2D39B"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Back rim -->
|
||||||
|
<path
|
||||||
|
d="M7 27 16 22 24 26 32 22 40 25 49 21 57 25"
|
||||||
|
fill="none"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2.75"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Leafy greens -->
|
||||||
|
<path
|
||||||
|
d="M42 28C39 21 42 12 49 7c2 3 2 6 1 9 3-2 6-2 8 0-1 5-5 9-12 13Z"
|
||||||
|
fill="#8EC866"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2.5"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M45 27 53 15M47 22l7-1M49 18l-1-5"
|
||||||
|
fill="none"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Carrot leaves -->
|
||||||
|
<path
|
||||||
|
d="
|
||||||
|
M17 14c-2-4-1-7 0-10 3 3 4 6 3 10
|
||||||
|
m0 0c0-5 2-8 5-10 1 5-1 8-5 11
|
||||||
|
"
|
||||||
|
fill="#8EC866"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Carrot -->
|
||||||
|
<path
|
||||||
|
d="M13 18c3-4 9-5 13-2l-3 20-5 2Z"
|
||||||
|
fill="#F29A3F"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2.5"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="m16 24 7-2m-6 7 5-2"
|
||||||
|
fill="none"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Tomato -->
|
||||||
|
<path
|
||||||
|
d="M27 25c0-6 4-10 10-10s10 4 10 10c0 7-4 12-10 12S27 32 27 25Z"
|
||||||
|
fill="#E65A46"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2.5"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="m37 15-4 5 4-1 4 2-1-5"
|
||||||
|
fill="#78B75B"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Front and sides of the paper bag -->
|
||||||
|
<path
|
||||||
|
d="
|
||||||
|
M7 27
|
||||||
|
L16 31
|
||||||
|
L23 27
|
||||||
|
L31 32
|
||||||
|
L39 28
|
||||||
|
L47 31
|
||||||
|
L57 25
|
||||||
|
L55 51
|
||||||
|
L45 59
|
||||||
|
L11 51
|
||||||
|
Z
|
||||||
|
"
|
||||||
|
fill="#F2D39B"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2.75"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Front opening edge -->
|
||||||
|
<path
|
||||||
|
d="M7 27 16 31 23 27 31 32 39 28 47 31 57 25"
|
||||||
|
fill="none"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2.75"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Side-panel seam and paper creases -->
|
||||||
|
<path
|
||||||
|
d="M47 31 45 59M45 59l10-8M15 36l1 9"
|
||||||
|
fill="none"
|
||||||
|
stroke="#1F4938"
|
||||||
|
stroke-width="2.25"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.6 KiB |
+6
-10
@@ -6,31 +6,27 @@ function b64ToBytes(b64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("passkey-login").addEventListener("click", async () => {
|
document.getElementById("passkey-login").addEventListener("click", async () => {
|
||||||
const email = document.getElementById("email").value;
|
const email = document.getElementById("email").value.trim();
|
||||||
if (!email) {
|
|
||||||
alert("Enter your email first.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const start = await fetch("/auth/passkey/login/start", {
|
const start = await fetch("/auth/passkey/login/start", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({ email }),
|
body: JSON.stringify({ email }),
|
||||||
});
|
});
|
||||||
if (!start.ok) {
|
if (!start.ok) {
|
||||||
alert("No passkey found for that email.");
|
alert("No passkey found for that account.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const options = await start.json();
|
const data = await start.json();
|
||||||
const pk = options.publicKey;
|
const pk = data.publicKey;
|
||||||
pk.challenge = b64ToBytes(pk.challenge);
|
pk.challenge = b64ToBytes(pk.challenge);
|
||||||
if (pk.allowCredentials) {
|
if (pk.allowCredentials) {
|
||||||
pk.allowCredentials.forEach((c) => (c.id = b64ToBytes(c.id)));
|
pk.allowCredentials.forEach((c) => (c.id = b64ToBytes(c.id)));
|
||||||
}
|
}
|
||||||
const credential = await navigator.credentials.get(options);
|
const credential = await navigator.credentials.get({ publicKey: pk });
|
||||||
const finish = await fetch("/auth/passkey/login/finish", {
|
const finish = await fetch("/auth/passkey/login/finish", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({ response: credential }),
|
body: JSON.stringify({ token: data.token, response: credential }),
|
||||||
});
|
});
|
||||||
if (finish.ok) {
|
if (finish.ok) {
|
||||||
window.location.href = "/lists";
|
window.location.href = "/lists";
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// Toggle password visibility so users can check for typos, especially on mobile.
|
||||||
|
document.querySelectorAll(".password-toggle").forEach(function (button) {
|
||||||
|
button.addEventListener("pointerdown", function (event) {
|
||||||
|
// Toggle on press (not click) for an instant response. preventScroll avoids
|
||||||
|
// a scroll-to-input animation that makes rapid toggling feel laggy, and
|
||||||
|
// keeping focus on the input keeps the mobile keyboard open.
|
||||||
|
event.preventDefault();
|
||||||
|
var input = document.getElementById(button.getAttribute("data-toggle-for"));
|
||||||
|
if (!input) return;
|
||||||
|
var showing = input.type === "text";
|
||||||
|
input.type = showing ? "password" : "text";
|
||||||
|
button.textContent = showing ? "Show" : "Hide";
|
||||||
|
button.setAttribute("aria-label", showing ? "Show password" : "Hide password");
|
||||||
|
input.focus({ preventScroll: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// Keep the screen awake while a rewards barcode is on screen so the cashier
|
||||||
|
// can scan it without the display dimming or locking. This mirrors how wallet
|
||||||
|
// apps behave when showing a barcode. The Screen Wake Lock API is best-effort:
|
||||||
|
// it may be rejected (e.g. low battery) or auto-released when the tab is hidden,
|
||||||
|
// so we re-acquire whenever the page becomes visible again.
|
||||||
|
(function () {
|
||||||
|
var wakeLock = null;
|
||||||
|
|
||||||
|
function requestWakeLock() {
|
||||||
|
if (!("wakeLock" in navigator)) return;
|
||||||
|
navigator.wakeLock
|
||||||
|
.request("screen")
|
||||||
|
.then(function (sentinel) {
|
||||||
|
wakeLock = sentinel;
|
||||||
|
})
|
||||||
|
.catch(function () {
|
||||||
|
// Best-effort only; ignore failures (unsupported, low battery, etc.).
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-acquire if the lock was released (e.g. the tab was hidden) and the user
|
||||||
|
// returns to the page.
|
||||||
|
document.addEventListener("visibilitychange", function () {
|
||||||
|
if (document.visibilityState === "visible" && wakeLock === null) {
|
||||||
|
requestWakeLock();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
requestWakeLock();
|
||||||
|
})();
|
||||||
+146
-2
@@ -38,7 +38,7 @@ a { color: inherit; }
|
|||||||
}
|
}
|
||||||
|
|
||||||
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: -.03em; }
|
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: -.03em; }
|
||||||
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px 11px 11px 3px; background: var(--deep-sage); color: white; transform: rotate(-6deg); }
|
.brand-mark { display: block; width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
|
||||||
.site-nav { display: flex; align-items: center; gap: 6px; }
|
.site-nav { display: flex; align-items: center; gap: 6px; }
|
||||||
.site-nav a {
|
.site-nav a {
|
||||||
padding: 8px 14px;
|
padding: 8px 14px;
|
||||||
@@ -67,14 +67,25 @@ h3 { margin-bottom: 6px; font-size: 1rem; }
|
|||||||
.muted { color: var(--muted); }
|
.muted { color: var(--muted); }
|
||||||
|
|
||||||
.page-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 34px; }
|
.page-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 34px; }
|
||||||
|
.page-heading h1.page-title { font-size: clamp(1.6rem, 3.2vw, 2.3rem); }
|
||||||
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .8fr); gap: 22px; align-items: start; }
|
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .8fr); gap: 22px; align-items: start; }
|
||||||
.panel { padding: 26px; border: 1px solid rgba(221, 225, 210, .9); border-radius: 24px; background: rgba(255, 253, 248, .88); box-shadow: var(--shadow); }
|
.panel { padding: 26px; border: 1px solid rgba(221, 225, 210, .9); border-radius: 24px; background: rgba(255, 253, 248, .88); box-shadow: var(--shadow); }
|
||||||
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
|
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
|
||||||
|
.archive-link { margin-left: auto; color: var(--muted); font-size: .78rem; font-weight: 700; text-decoration: none; }
|
||||||
|
.archive-link:hover { color: var(--deep-sage); }
|
||||||
.count-badge { display: inline-grid; place-items: center; min-width: 27px; height: 27px; padding: 0 8px; border-radius: 99px; color: var(--deep-sage); background: #e8f0e1; font-size: .78rem; font-weight: 800; }
|
.count-badge { display: inline-grid; place-items: center; min-width: 27px; height: 27px; padding: 0 8px; border-radius: 99px; color: var(--deep-sage); background: #e8f0e1; font-size: .78rem; font-weight: 800; }
|
||||||
.stack { display: grid; gap: 9px; }
|
.stack { display: grid; gap: 9px; }
|
||||||
.stack label { color: var(--muted); font-size: .82rem; font-weight: 700; }
|
.stack label { color: var(--muted); font-size: .82rem; font-weight: 700; }
|
||||||
input { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: #fff; }
|
input { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: #fff; }
|
||||||
input:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
|
input:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
|
||||||
|
.password-field { position: relative; }
|
||||||
|
.password-field input { padding-right: 64px; }
|
||||||
|
.password-toggle { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); min-height: 32px; padding: 5px 10px; border: 0; border-radius: 9px; cursor: pointer; color: var(--deep-sage); background: #e7f0e1; font-weight: 800; font-size: .78rem; }
|
||||||
|
.password-toggle:hover { background: #dbe9d2; }
|
||||||
|
select { width: 100%; min-height: 46px; padding: 10px 34px 10px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: #fff; font: inherit; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' fill='none' stroke='%2355715d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
|
||||||
|
select:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
|
||||||
|
select option { color: var(--ink); background: #fff; }
|
||||||
|
select option:checked { color: var(--deep-sage); font-weight: 700; }
|
||||||
textarea { width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: #fff; font: inherit; resize: vertical; }
|
textarea { width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: #fff; font: inherit; resize: vertical; }
|
||||||
textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
|
textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
|
||||||
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 17px; border: 0; border-radius: 12px; cursor: pointer; text-decoration: none; font-weight: 800; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
|
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 17px; border: 0; border-radius: 12px; cursor: pointer; text-decoration: none; font-weight: 800; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
|
||||||
@@ -91,12 +102,18 @@ textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85,
|
|||||||
.list-card-copy { display: grid; flex: 1; gap: 2px; }
|
.list-card-copy { display: grid; flex: 1; gap: 2px; }
|
||||||
.list-card-copy small { color: var(--muted); font-size: .75rem; }
|
.list-card-copy small { color: var(--muted); font-size: .75rem; }
|
||||||
.list-card-arrow { color: var(--muted); font-size: 1.25rem; }
|
.list-card-arrow { color: var(--muted); font-size: 1.25rem; }
|
||||||
|
.archived-list-card { opacity: .72; }
|
||||||
|
.archived-list-card .list-card-icon { color: var(--muted); background: #eef0ea; }
|
||||||
|
.archived-list-card .list-card-copy { align-items: flex-start; }
|
||||||
|
.archived-list-card form { margin-left: auto; }
|
||||||
|
.archived-banner { margin-bottom: 18px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: #f1f3ec; font-size: .82rem; font-weight: 700; }
|
||||||
.empty-state { padding: 35px 18px 24px; text-align: center; color: var(--muted); }
|
.empty-state { padding: 35px 18px 24px; text-align: center; color: var(--muted); }
|
||||||
.empty-mark { display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 15px; border-radius: 18px; color: var(--deep-sage); background: #edf3e8; font-size: 1.8rem; }
|
.empty-mark { display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 15px; border-radius: 18px; color: var(--deep-sage); background: #edf3e8; font-size: 1.8rem; }
|
||||||
.empty-state h3 { color: var(--ink); }
|
.empty-state h3 { color: var(--ink); }
|
||||||
|
|
||||||
.auth-card { width: min(100%, 480px); margin: 7vh auto 0; padding: clamp(27px, 6vw, 54px); border: 1px solid var(--line); border-radius: 28px; background: rgba(255, 253, 248, .9); box-shadow: var(--shadow); }
|
.auth-card { width: min(100%, 480px); margin: 7vh auto 0; padding: clamp(27px, 6vw, 54px); border: 1px solid var(--line); border-radius: 28px; background: rgba(255, 253, 248, .9); box-shadow: var(--shadow); }
|
||||||
.auth-card .button { margin-top: 11px; }
|
.auth-card .button { margin-top: 11px; }
|
||||||
|
#passkey-login { width: 100%; }
|
||||||
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 4px; color: var(--muted); font-size: .8rem; }
|
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 4px; color: var(--muted); font-size: .8rem; }
|
||||||
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
|
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
|
||||||
.passkey-list { display: grid; gap: 8px; margin-bottom: 16px; }
|
.passkey-list { display: grid; gap: 8px; margin-bottom: 16px; }
|
||||||
@@ -107,6 +124,7 @@ textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85,
|
|||||||
.auth-switch a { color: var(--deep-sage); font-weight: 800; }
|
.auth-switch a { color: var(--deep-sage); font-weight: 800; }
|
||||||
.alert { margin-bottom: 18px; padding: 12px 14px; border-radius: 12px; font-size: .9rem; }
|
.alert { margin-bottom: 18px; padding: 12px 14px; border-radius: 12px; font-size: .9rem; }
|
||||||
.alert-error { color: #874d40; background: #fbe7e0; }
|
.alert-error { color: #874d40; background: #fbe7e0; }
|
||||||
|
.alert-success { color: #3d6b4f; background: #e4f2e6; }
|
||||||
|
|
||||||
.list-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 27px; }
|
.list-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 27px; }
|
||||||
.back-link { color: var(--muted); font-size: .85rem; font-weight: 700; text-decoration: none; }
|
.back-link { color: var(--muted); font-size: .85rem; font-weight: 700; text-decoration: none; }
|
||||||
@@ -126,7 +144,8 @@ textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85,
|
|||||||
.list-heading { display: flex; justify-content: space-between; margin-bottom: 25px; }
|
.list-heading { display: flex; justify-content: space-between; margin-bottom: 25px; }
|
||||||
.list-heading h1 { max-width: 100%; margin-bottom: 5px; overflow-wrap: anywhere; font-size: clamp(1.45rem, 2.8vw, 2.05rem); }
|
.list-heading h1 { max-width: 100%; margin-bottom: 5px; overflow-wrap: anywhere; font-size: clamp(1.45rem, 2.8vw, 2.05rem); }
|
||||||
.list-meta { margin: 0; color: var(--muted); font-size: .85rem; }
|
.list-meta { margin: 0; color: var(--muted); font-size: .85rem; }
|
||||||
.add-item-form { display: grid; grid-template-columns: minmax(0, 1fr) 90px 145px auto; gap: 8px; margin-bottom: 19px; }
|
.meal-category-label { margin-left: 10px; color: var(--muted); font-size: .8em; font-weight: 500; white-space: nowrap; }
|
||||||
|
.add-item-form { display: grid; grid-template-columns: minmax(0, 1fr) 145px 90px auto; gap: 8px; margin-bottom: 19px; }
|
||||||
.add-item-form input { min-height: 50px; }
|
.add-item-form input { min-height: 50px; }
|
||||||
.add-item-form select { min-height: 50px; }
|
.add-item-form select { min-height: 50px; }
|
||||||
.add-button { min-height: 50px; }
|
.add-button { min-height: 50px; }
|
||||||
@@ -134,11 +153,14 @@ textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85,
|
|||||||
.item-list { display: grid; gap: 6px; }
|
.item-list { display: grid; gap: 6px; }
|
||||||
.category-group + .category-group { margin-top: 18px; }
|
.category-group + .category-group { margin-top: 18px; }
|
||||||
.category-heading { margin: 0 7px 4px; color: var(--deep-sage); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
|
.category-heading { margin: 0 7px 4px; color: var(--deep-sage); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
|
||||||
|
.ingredients-divider { margin: 26px 0 18px; border: 0; border-top: 1px solid var(--line); }
|
||||||
.item-row { display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 9px 7px 9px 10px; border-bottom: 1px solid #edf0e6; }
|
.item-row { display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 9px 7px 9px 10px; border-bottom: 1px solid #edf0e6; }
|
||||||
.item-row:last-child { border-bottom: 0; }
|
.item-row:last-child { border-bottom: 0; }
|
||||||
.check-form { flex: 0 0 auto; }
|
.check-form { flex: 0 0 auto; }
|
||||||
.check-button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 2px solid #c8d6c1; border-radius: 9px; color: #fff; background: transparent; cursor: pointer; font-size: .88rem; font-weight: 900; }
|
.check-button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 2px solid #c8d6c1; border-radius: 9px; color: #fff; background: transparent; cursor: pointer; font-size: .88rem; font-weight: 900; }
|
||||||
.is-checked .check-button { border-color: var(--deep-sage); background: var(--deep-sage); }
|
.is-checked .check-button { border-color: var(--deep-sage); background: var(--deep-sage); }
|
||||||
|
.check-button-static { cursor: default; }
|
||||||
|
.is-checked .check-button-static { border-color: var(--deep-sage); background: var(--deep-sage); }
|
||||||
.item-copy { display: grid; grid-template-columns: auto 1fr; flex: 1; min-width: 0; gap: 2px 7px; align-items: baseline; }
|
.item-copy { display: grid; grid-template-columns: auto 1fr; flex: 1; min-width: 0; gap: 2px 7px; align-items: baseline; }
|
||||||
.item-copy strong { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.item-copy strong { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
.item-qty { grid-column: 1; grid-row: 1; color: var(--muted); font-weight: 700; white-space: nowrap; }
|
.item-qty { grid-column: 1; grid-row: 1; color: var(--muted); font-weight: 700; white-space: nowrap; }
|
||||||
@@ -207,6 +229,10 @@ textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85,
|
|||||||
.edit-form { margin-bottom: 12px; }
|
.edit-form { margin-bottom: 12px; }
|
||||||
.edit-form input { min-height: 38px; padding: 7px 10px; font-size: .85rem; }
|
.edit-form input { min-height: 38px; padding: 7px 10px; font-size: .85rem; }
|
||||||
.danger-link { padding: 0; border: 0; color: var(--coral); background: none; cursor: pointer; font-size: .8rem; font-weight: 800; }
|
.danger-link { padding: 0; border: 0; color: var(--coral); background: none; cursor: pointer; font-size: .8rem; font-weight: 800; }
|
||||||
|
.bordered-delete { padding: 7px 14px; border: 1px solid var(--coral); border-radius: 10px; background: none; }
|
||||||
|
.bordered-delete:hover { background: #fbeae4; }
|
||||||
|
.button-danger { width: 100%; color: var(--coral); background: #fbeae4; }
|
||||||
|
.button-danger:hover { background: #f7ddd4; }
|
||||||
.empty-items { padding: 34px 10px 18px; color: var(--muted); text-align: center; }
|
.empty-items { padding: 34px 10px 18px; color: var(--muted); text-align: center; }
|
||||||
.empty-items-icon { display: block; margin-bottom: 7px; color: var(--yellow); font-size: 1.7rem; }
|
.empty-items-icon { display: block; margin-bottom: 7px; color: var(--yellow); font-size: 1.7rem; }
|
||||||
.empty-items p { margin-bottom: 2px; color: var(--ink); font-weight: 800; }
|
.empty-items p { margin-bottom: 2px; color: var(--ink); font-weight: 800; }
|
||||||
@@ -217,12 +243,28 @@ textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85,
|
|||||||
.category-form input { min-height: 38px; padding: 7px 10px; font-size: .84rem; }
|
.category-form input { min-height: 38px; padding: 7px 10px; font-size: .84rem; }
|
||||||
.category-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
|
.category-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
|
||||||
.category-chip { padding: 5px 9px; border-radius: 99px; color: var(--deep-sage); background: #edf3e8; font-size: .72rem; font-weight: 800; }
|
.category-chip { padding: 5px 9px; border-radius: 99px; color: var(--deep-sage); background: #edf3e8; font-size: .72rem; font-weight: 800; }
|
||||||
|
/* Meal categories side panel */
|
||||||
|
.meal-category-list { display: grid; gap: 2px; margin-top: 14px; }
|
||||||
|
.meal-category-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 4px; border-bottom: 1px solid #edf0e6; }
|
||||||
|
.meal-category-row:last-child { border-bottom: 0; }
|
||||||
|
.meal-category-name { font-size: .9rem; font-weight: 700; }
|
||||||
|
.meal-category-delete { padding: 2px 6px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: .8rem; line-height: 1; }
|
||||||
|
.meal-category-delete:hover { color: var(--coral); background: #fbeae4; }
|
||||||
.category-empty { margin: 13px 0 0; font-size: .8rem; }
|
.category-empty { margin: 13px 0 0; font-size: .8rem; }
|
||||||
.category-result { margin-top: 10px; }
|
.category-result { margin-top: 10px; }
|
||||||
.category-success { margin: 0; color: var(--deep-sage); font-size: .76rem; font-weight: 800; }
|
.category-success { margin: 0; color: var(--deep-sage); font-size: .76rem; font-weight: 800; }
|
||||||
.presence-list { display: grid; gap: 12px; }
|
.presence-list { display: grid; gap: 12px; }
|
||||||
.presence-person { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 700; }
|
.presence-person { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 700; }
|
||||||
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px; color: var(--deep-sage); background: #e6f0df; font-size: .7rem; font-weight: 900; }
|
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px; color: var(--deep-sage); background: #e6f0df; font-size: .7rem; font-weight: 900; }
|
||||||
|
.list-meals { display: grid; gap: 8px; }
|
||||||
|
.list-meal-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid #edf0e6; }
|
||||||
|
.list-meal-row:last-child { border-bottom: 0; }
|
||||||
|
.list-meal-icon { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; border-radius: 10px; color: var(--deep-sage); background: #eef4e9; font-size: .95rem; }
|
||||||
|
.list-meal-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; font-weight: 700; }
|
||||||
|
.list-meal-remove { margin: 0; flex: 0 0 auto; }
|
||||||
|
.list-meal-remove-button { padding: 2px 7px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: .8rem; line-height: 1; }
|
||||||
|
.list-meal-remove-button:hover { color: var(--coral); background: #fbeae4; }
|
||||||
|
.list-meals-panel .add-meal-button { margin-top: 12px; width: 100%; }
|
||||||
.sharing-panel p, .tip-panel p { color: var(--muted); font-size: .86rem; }
|
.sharing-panel p, .tip-panel p { color: var(--muted); font-size: .86rem; }
|
||||||
.invite-result { margin-top: 15px; }
|
.invite-result { margin-top: 15px; }
|
||||||
.invite-link-result { padding: 11px; border-radius: 12px; background: #f1f5ec; }
|
.invite-link-result { padding: 11px; border-radius: 12px; background: #f1f5ec; }
|
||||||
@@ -336,6 +378,11 @@ textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85,
|
|||||||
.meal-picker-empty { padding: 34px 22px 30px; text-align: center; color: var(--muted); }
|
.meal-picker-empty { padding: 34px 22px 30px; text-align: center; color: var(--muted); }
|
||||||
.meal-picker-empty h3 { color: var(--ink); }
|
.meal-picker-empty h3 { color: var(--ink); }
|
||||||
.meal-picker-empty p { margin-bottom: 18px; }
|
.meal-picker-empty p { margin-bottom: 18px; }
|
||||||
|
.meal-filter-bar { margin: -6px 0 18px; }
|
||||||
|
.meal-filter-bar input { min-height: 40px; padding: 8px 12px; font-size: .9rem; }
|
||||||
|
.meal-filter-bar-picker { margin: 14px 24px 4px; }
|
||||||
|
.meal-filter-empty { padding: 28px 18px; text-align: center; color: var(--muted); }
|
||||||
|
.meal-filter-empty p { margin: 0; }
|
||||||
|
|
||||||
@media (max-width: 780px) {
|
@media (max-width: 780px) {
|
||||||
.site-header, .site-main, .site-footer { width: min(100% - 28px, 600px); }
|
.site-header, .site-main, .site-footer { width: min(100% - 28px, 600px); }
|
||||||
@@ -361,3 +408,100 @@ textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85,
|
|||||||
.side-column { grid-template-columns: 1fr; }
|
.side-column { grid-template-columns: 1fr; }
|
||||||
.site-footer { margin-bottom: 20px; }
|
.site-footer { margin-bottom: 20px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Rewards cards */
|
||||||
|
.rewards-grid { display: grid; gap: 16px; }
|
||||||
|
.rewards-card {
|
||||||
|
position: relative;
|
||||||
|
padding: 18px;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 18px;
|
||||||
|
background: #fff;
|
||||||
|
transition: border-color .16s ease, transform .16s ease;
|
||||||
|
}
|
||||||
|
.rewards-card:hover { border-color: var(--sage); transform: translateY(-1px); }
|
||||||
|
/* Stretched link: makes the whole card clickable to open the scan view. */
|
||||||
|
.rewards-card-link {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
border-radius: inherit;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
.rewards-card-heading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 14px;
|
||||||
|
}
|
||||||
|
.rewards-card-heading strong { font-size: 1.05rem; }
|
||||||
|
.rewards-barcode {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 14px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.rewards-barcode svg { width: 100%; height: auto; max-width: 340px; }
|
||||||
|
.rewards-number {
|
||||||
|
margin: 12px 0 0;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: .85rem;
|
||||||
|
letter-spacing: .08em;
|
||||||
|
}
|
||||||
|
.rewards-unencodable {
|
||||||
|
display: block;
|
||||||
|
color: var(--coral);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
/* Keep the Remove button above the stretched link so it stays clickable. */
|
||||||
|
.rewards-card-heading form { position: relative; z-index: 2; }
|
||||||
|
|
||||||
|
/* Single-card scan view */
|
||||||
|
.scan-page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 22px;
|
||||||
|
padding: 12px 0 40px;
|
||||||
|
}
|
||||||
|
.scan-back { align-self: flex-start; }
|
||||||
|
.scan-card {
|
||||||
|
width: min(100%, 460px);
|
||||||
|
padding: clamp(24px, 6vw, 42px);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 28px;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.scan-store { margin: 4px 0 26px; font-size: clamp(1.3rem, 4vw, 1.7rem); }
|
||||||
|
.scan-barcode {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 22px;
|
||||||
|
border-radius: 14px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.scan-barcode svg {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
max-width: 420px;
|
||||||
|
}
|
||||||
|
.scan-card .rewards-number {
|
||||||
|
margin-top: 18px;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 46px;
|
||||||
|
padding: 10px 13px;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 12px;
|
||||||
|
outline: none;
|
||||||
|
color: var(--ink);
|
||||||
|
background: #fff;
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
select:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
|
||||||
|
|||||||
Reference in New Issue
Block a user