forge
Explore
Log in

Don't you dare go Hollow

Bump remaining crates to latest

Browse files at this commit

25140f308a711d4090fa75bb29558a3f5335587cAhmet Kaan GümüşParent: ce3c543
  • chore
    • bump remaining crates to latest
Show full message
chore: bump remaining crates to latest

topcoat 0.8, ulid 3, chacha20poly1305 0.11, base64 0.23, rsa 0.10-rc.18.
Cargo.lockmodified+179 -146
@@ -18,6 +18,16 @@ dependencies = [
18 "generic-array",18 "generic-array",
19 ]19 ]
20 20
21+[[package]]
22+name = "aead"
23+version = "0.6.1"
24+source = "registry+https://github.com/rust-lang/crates.io-index"
25+checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99"
26+dependencies = [
27+ "crypto-common 0.2.2",
28+ "inout 0.2.2",
29+]
30+
21 [[package]]31 [[package]]
22 name = "aegis"32 name = "aegis"
23 version = "0.9.15"33 version = "0.9.15"
@@ -35,7 +45,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
35 checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"45 checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
36 dependencies = [46 dependencies = [
37 "cfg-if",47 "cfg-if",
38- "cipher",48+ "cipher 0.4.4",
39 "cpufeatures 0.2.17",49 "cpufeatures 0.2.17",
40 ]50 ]
41 51
@@ -45,9 +55,9 @@ version = "0.10.3"
45 source = "registry+https://github.com/rust-lang/crates.io-index"55 source = "registry+https://github.com/rust-lang/crates.io-index"
46 checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"56 checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"
47 dependencies = [57 dependencies = [
48- "aead",58+ "aead 0.5.2",
49 "aes",59 "aes",
50- "cipher",60+ "cipher 0.4.4",
51 "ctr",61 "ctr",
52 "ghash",62 "ghash",
53 "subtle",63 "subtle",
@@ -293,6 +303,12 @@ dependencies = [
293 "pkg-config",303 "pkg-config",
294 ]304 ]
295 305
306+[[package]]
307+name = "base16ct"
308+version = "1.0.0"
309+source = "registry+https://github.com/rust-lang/crates.io-index"
310+checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6"
311+
296 [[package]]312 [[package]]
297 name = "base64"313 name = "base64"
298 version = "0.22.1"314 version = "0.22.1"
@@ -537,17 +553,6 @@ version = "0.1.1"
537 source = "registry+https://github.com/rust-lang/crates.io-index"553 source = "registry+https://github.com/rust-lang/crates.io-index"
538 checksum = "18758054972164c3264f7c8386f5fc6da6114cb46b619fd365d4e3b2dc3ae487"554 checksum = "18758054972164c3264f7c8386f5fc6da6114cb46b619fd365d4e3b2dc3ae487"
539 555
540-[[package]]
541-name = "chacha20"
542-version = "0.9.1"
543-source = "registry+https://github.com/rust-lang/crates.io-index"
544-checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
545-dependencies = [
546- "cfg-if",
547- "cipher",
548- "cpufeatures 0.2.17",
549-]
550-
551 [[package]]556 [[package]]
552 name = "chacha20"557 name = "chacha20"
553 version = "0.10.2"558 version = "0.10.2"
@@ -555,21 +560,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
555 checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"560 checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
556 dependencies = [561 dependencies = [
557 "cfg-if",562 "cfg-if",
563+ "cipher 0.5.2",
558 "cpufeatures 0.3.1",564 "cpufeatures 0.3.1",
559 "rand_core 0.10.1",565 "rand_core 0.10.1",
560 ]566 ]
561 567
562 [[package]]568 [[package]]
563 name = "chacha20poly1305"569 name = "chacha20poly1305"
564-version = "0.10.1"570+version = "0.11.0"
565 source = "registry+https://github.com/rust-lang/crates.io-index"571 source = "registry+https://github.com/rust-lang/crates.io-index"
566-checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"572+checksum = "9b89e1c441e926b9c82a8d023f6e1b7ae0adcfaa7d621814e4d60789bac751cb"
567 dependencies = [573 dependencies = [
568- "aead",574+ "aead 0.6.1",
569- "chacha20 0.9.1",575+ "chacha20",
570- "cipher",576+ "cipher 0.5.2",
571 "poly1305",577 "poly1305",
572- "zeroize",
573 ]578 ]
574 579
575 [[package]]580 [[package]]
@@ -592,8 +597,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
592 checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"597 checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
593 dependencies = [598 dependencies = [
594 "crypto-common 0.1.7",599 "crypto-common 0.1.7",
595- "inout",600+ "inout 0.1.4",
596- "zeroize",601+]
602+
603+[[package]]
604+name = "cipher"
605+version = "0.5.2"
606+source = "registry+https://github.com/rust-lang/crates.io-index"
607+checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"
608+dependencies = [
609+ "block-buffer 0.12.1",
610+ "crypto-common 0.2.2",
611+ "inout 0.2.2",
597 ]612 ]
598 613
599 [[package]]614 [[package]]
@@ -698,12 +713,6 @@ dependencies = [
698 "crossbeam-utils",713 "crossbeam-utils",
699 ]714 ]
700 715
701-[[package]]
702-name = "const-oid"
703-version = "0.9.6"
704-source = "registry+https://github.com/rust-lang/crates.io-index"
705-checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
706-
707 [[package]]716 [[package]]
708 name = "const-oid"717 name = "const-oid"
709 version = "0.10.2"718 version = "0.10.2"
@@ -750,6 +759,12 @@ version = "1.0.0"
750 source = "registry+https://github.com/rust-lang/crates.io-index"759 source = "registry+https://github.com/rust-lang/crates.io-index"
751 checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"760 checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
752 761
762+[[package]]
763+name = "cpubits"
764+version = "0.1.1"
765+source = "registry+https://github.com/rust-lang/crates.io-index"
766+checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
767+
753 [[package]]768 [[package]]
754 name = "cpufeatures"769 name = "cpufeatures"
755 version = "0.2.17"770 version = "0.2.17"
@@ -826,6 +841,20 @@ version = "0.2.4"
826 source = "registry+https://github.com/rust-lang/crates.io-index"841 source = "registry+https://github.com/rust-lang/crates.io-index"
827 checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"842 checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
828 843
844+[[package]]
845+name = "crypto-bigint"
846+version = "0.7.5"
847+source = "registry+https://github.com/rust-lang/crates.io-index"
848+checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271"
849+dependencies = [
850+ "cpubits",
851+ "ctutils",
852+ "num-traits",
853+ "rand_core 0.10.1",
854+ "serdect",
855+ "zeroize",
856+]
857+
829 [[package]]858 [[package]]
830 name = "crypto-common"859 name = "crypto-common"
831 version = "0.1.7"860 version = "0.1.7"
@@ -843,7 +872,19 @@ version = "0.2.2"
843 source = "registry+https://github.com/rust-lang/crates.io-index"872 source = "registry+https://github.com/rust-lang/crates.io-index"
844 checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"873 checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
845 dependencies = [874 dependencies = [
875+ "getrandom 0.4.3",
846 "hybrid-array",876 "hybrid-array",
877+ "rand_core 0.10.1",
878+]
879+
880+[[package]]
881+name = "crypto-primes"
882+version = "0.7.2"
883+source = "registry+https://github.com/rust-lang/crates.io-index"
884+checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f"
885+dependencies = [
886+ "crypto-bigint",
887+ "rand_core 0.10.1",
847 ]888 ]
848 889
849 [[package]]890 [[package]]
@@ -852,7 +893,7 @@ version = "0.9.2"
852 source = "registry+https://github.com/rust-lang/crates.io-index"893 source = "registry+https://github.com/rust-lang/crates.io-index"
853 checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"894 checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
854 dependencies = [895 dependencies = [
855- "cipher",896+ "cipher 0.4.4",
856 ]897 ]
857 898
858 [[package]]899 [[package]]
@@ -912,11 +953,11 @@ checksum = "c286de4e81ea2590afc24d754e0f83810c566f50a1388fa75ebd57928c0d9745"
912 953
913 [[package]]954 [[package]]
914 name = "der"955 name = "der"
915-version = "0.7.10"956+version = "0.8.2"
916 source = "registry+https://github.com/rust-lang/crates.io-index"957 source = "registry+https://github.com/rust-lang/crates.io-index"
917-checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"958+checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a"
918 dependencies = [959 dependencies = [
919- "const-oid 0.9.6",960+ "const-oid",
920 "pem-rfc7468",961 "pem-rfc7468",
921 "zeroize",962 "zeroize",
922 ]963 ]
@@ -937,7 +978,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
937 checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"978 checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
938 dependencies = [979 dependencies = [
939 "block-buffer 0.10.4",980 "block-buffer 0.10.4",
940- "const-oid 0.9.6",
941 "crypto-common 0.1.7",981 "crypto-common 0.1.7",
942 "subtle",982 "subtle",
943 ]983 ]
@@ -949,7 +989,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
949 checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"989 checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
950 dependencies = [990 dependencies = [
951 "block-buffer 0.12.1",991 "block-buffer 0.12.1",
952- "const-oid 0.10.2",992+ "const-oid",
953 "crypto-common 0.2.2",993 "crypto-common 0.2.2",
954 "ctutils",994 "ctutils",
955 ]995 ]
@@ -1782,16 +1822,15 @@ dependencies = [
1782 name = "im-client"1822 name = "im-client"
1783 version = "0.1.0"1823 version = "0.1.0"
1784 dependencies = [1824 dependencies = [
1785- "base64 0.22.1",1825+ "base64 0.23.1",
1786 "chacha20poly1305",1826 "chacha20poly1305",
1787 "http",1827 "http",
1788 "rand 0.10.2",1828 "rand 0.10.2",
1789- "rand_core 0.6.4",1829+ "rand_core 0.10.1",
1790 "reqwest",1830 "reqwest",
1791 "rsa",1831 "rsa",
1792 "serde",1832 "serde",
1793 "serde_json",1833 "serde_json",
1794- "sha2 0.10.9",
1795 "sha2 0.11.0",1834 "sha2 0.11.0",
1796 "subtle",1835 "subtle",
1797 "thiserror",1836 "thiserror",
@@ -1805,17 +1844,16 @@ name = "im-core"
1805 version = "0.1.0"1844 version = "0.1.0"
1806 dependencies = [1845 dependencies = [
1807 "argon2",1846 "argon2",
1808- "base64 0.22.1",1847+ "base64 0.23.1",
1809 "chacha20poly1305",1848 "chacha20poly1305",
1810 "data-encoding",1849 "data-encoding",
1811 "hmac 0.13.0",1850 "hmac 0.13.0",
1812 "rand 0.10.2",1851 "rand 0.10.2",
1813- "rand_core 0.6.4",1852+ "rand_core 0.10.1",
1814 "rsa",1853 "rsa",
1815 "serde",1854 "serde",
1816 "serde_json",1855 "serde_json",
1817 "sha1 0.11.0",1856 "sha1 0.11.0",
1818- "sha2 0.10.9",
1819 "sha2 0.11.0",1857 "sha2 0.11.0",
1820 "subtle",1858 "subtle",
1821 "tempfile",1859 "tempfile",
@@ -1842,7 +1880,7 @@ dependencies = [
1842 name = "im-web"1880 name = "im-web"
1843 version = "0.1.0"1881 version = "0.1.0"
1844 dependencies = [1882 dependencies = [
1845- "base64 0.22.1",1883+ "base64 0.23.1",
1846 "data-encoding",1884 "data-encoding",
1847 "futures-util",1885 "futures-util",
1848 "grass",1886 "grass",
@@ -1880,6 +1918,15 @@ dependencies = [
1880 "generic-array",1918 "generic-array",
1881 ]1919 ]
1882 1920
1921+[[package]]
1922+name = "inout"
1923+version = "0.2.2"
1924+source = "registry+https://github.com/rust-lang/crates.io-index"
1925+checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"
1926+dependencies = [
1927+ "hybrid-array",
1928+]
1929+
1883 [[package]]1930 [[package]]
1884 name = "intrusive-collections"1931 name = "intrusive-collections"
1885 version = "0.9.7"1932 version = "0.9.7"
@@ -2029,9 +2076,6 @@ name = "lazy_static"
2029 version = "1.5.0"2076 version = "1.5.0"
2030 source = "registry+https://github.com/rust-lang/crates.io-index"2077 source = "registry+https://github.com/rust-lang/crates.io-index"
2031 checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"2078 checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
2032-dependencies = [
2033- "spin",
2034-]
2035 2079
2036 [[package]]2080 [[package]]
2037 name = "lazycell"2081 name = "lazycell"
@@ -2391,22 +2435,6 @@ dependencies = [
2391 "num-traits",2435 "num-traits",
2392 ]2436 ]
2393 2437
2394-[[package]]
2395-name = "num-bigint-dig"
2396-version = "0.8.6"
2397-source = "registry+https://github.com/rust-lang/crates.io-index"
2398-checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7"
2399-dependencies = [
2400- "lazy_static",
2401- "libm",
2402- "num-integer",
2403- "num-iter",
2404- "num-traits",
2405- "rand 0.8.8",
2406- "smallvec",
2407- "zeroize",
2408-]
2409-
2410 [[package]]2438 [[package]]
2411 name = "num-conv"2439 name = "num-conv"
2412 version = "0.2.2"2440 version = "0.2.2"
@@ -2422,16 +2450,6 @@ dependencies = [
2422 "num-traits",2450 "num-traits",
2423 ]2451 ]
2424 2452
2425-[[package]]
2426-name = "num-iter"
2427-version = "0.1.46"
2428-source = "registry+https://github.com/rust-lang/crates.io-index"
2429-checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b"
2430-dependencies = [
2431- "num-integer",
2432- "num-traits",
2433-]
2434-
2435 [[package]]2453 [[package]]
2436 name = "num-traits"2454 name = "num-traits"
2437 version = "0.2.19"2455 version = "0.2.19"
@@ -2439,7 +2457,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2439 checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"2457 checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
2440 dependencies = [2458 dependencies = [
2441 "autocfg",2459 "autocfg",
2442- "libm",
2443 ]2460 ]
2444 2461
2445 [[package]]2462 [[package]]
@@ -2546,9 +2563,9 @@ checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
2546 2563
2547 [[package]]2564 [[package]]
2548 name = "pem-rfc7468"2565 name = "pem-rfc7468"
2549-version = "0.7.0"2566+version = "1.0.0"
2550 source = "registry+https://github.com/rust-lang/crates.io-index"2567 source = "registry+https://github.com/rust-lang/crates.io-index"
2551-checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412"2568+checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9"
2552 dependencies = [2569 dependencies = [
2553 "base64ct",2570 "base64ct",
2554 ]2571 ]
@@ -2620,20 +2637,19 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
2620 2637
2621 [[package]]2638 [[package]]
2622 name = "pkcs1"2639 name = "pkcs1"
2623-version = "0.7.5"2640+version = "0.8.0-rc.4"
2624 source = "registry+https://github.com/rust-lang/crates.io-index"2641 source = "registry+https://github.com/rust-lang/crates.io-index"
2625-checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f"2642+checksum = "986d2e952779af96ea048f160fd9194e1751b4faea78bcf3ceb456efe008088e"
2626 dependencies = [2643 dependencies = [
2627 "der",2644 "der",
2628- "pkcs8",
2629 "spki",2645 "spki",
2630 ]2646 ]
2631 2647
2632 [[package]]2648 [[package]]
2633 name = "pkcs8"2649 name = "pkcs8"
2634-version = "0.10.2"2650+version = "0.11.0"
2635 source = "registry+https://github.com/rust-lang/crates.io-index"2651 source = "registry+https://github.com/rust-lang/crates.io-index"
2636-checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"2652+checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7"
2637 dependencies = [2653 dependencies = [
2638 "der",2654 "der",
2639 "spki",2655 "spki",
@@ -2661,13 +2677,12 @@ dependencies = [
2661 2677
2662 [[package]]2678 [[package]]
2663 name = "poly1305"2679 name = "poly1305"
2664-version = "0.8.0"2680+version = "0.9.1"
2665 source = "registry+https://github.com/rust-lang/crates.io-index"2681 source = "registry+https://github.com/rust-lang/crates.io-index"
2666-checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"2682+checksum = "6e2d0073b297041425c7c3df6eb4792d598a15323fe63346852b092eca02904c"
2667 dependencies = [2683 dependencies = [
2668- "cpufeatures 0.2.17",2684+ "cpufeatures 0.3.1",
2669- "opaque-debug",2685+ "universal-hash 0.6.1",
2670- "universal-hash",
2671 ]2686 ]
2672 2687
2673 [[package]]2688 [[package]]
@@ -2679,7 +2694,7 @@ dependencies = [
2679 "cfg-if",2694 "cfg-if",
2680 "cpufeatures 0.2.17",2695 "cpufeatures 0.2.17",
2681 "opaque-debug",2696 "opaque-debug",
2682- "universal-hash",2697+ "universal-hash 0.5.1",
2683 ]2698 ]
2684 2699
2685 [[package]]2700 [[package]]
@@ -2892,7 +2907,7 @@ version = "0.10.2"
2892 source = "registry+https://github.com/rust-lang/crates.io-index"2907 source = "registry+https://github.com/rust-lang/crates.io-index"
2893 checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"2908 checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"
2894 dependencies = [2909 dependencies = [
2895- "chacha20 0.10.2",2910+ "chacha20",
2896 "getrandom 0.4.3",2911 "getrandom 0.4.3",
2897 "rand_core 0.10.1",2912 "rand_core 0.10.1",
2898 ]2913 ]
@@ -3110,21 +3125,19 @@ dependencies = [
3110 3125
3111 [[package]]3126 [[package]]
3112 name = "rsa"3127 name = "rsa"
3113-version = "0.9.10"3128+version = "0.10.0-rc.18"
3114 source = "registry+https://github.com/rust-lang/crates.io-index"3129 source = "registry+https://github.com/rust-lang/crates.io-index"
3115-checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d"3130+checksum = "30b2aa4ba0d89f73d1e332df05be0eeab8840351c36ca5654341dfdb57bb3caf"
3116 dependencies = [3131 dependencies = [
3117- "const-oid 0.9.6",3132+ "const-oid",
3118- "digest 0.10.7",3133+ "crypto-bigint",
3119- "num-bigint-dig",3134+ "crypto-primes",
3120- "num-integer",3135+ "digest 0.11.3",
3121- "num-traits",
3122 "pkcs1",3136 "pkcs1",
3123 "pkcs8",3137 "pkcs8",
3124- "rand_core 0.6.4",3138+ "rand_core 0.10.1",
3125 "signature",3139 "signature",
3126 "spki",3140 "spki",
3127- "subtle",
3128 "zeroize",3141 "zeroize",
3129 ]3142 ]
3130 3143
@@ -3418,6 +3431,16 @@ dependencies = [
3418 "serde",3431 "serde",
3419 ]3432 ]
3420 3433
3434+[[package]]
3435+name = "serdect"
3436+version = "0.4.3"
3437+source = "registry+https://github.com/rust-lang/crates.io-index"
3438+checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e"
3439+dependencies = [
3440+ "base16ct",
3441+ "serde",
3442+]
3443+
3421 [[package]]3444 [[package]]
3422 name = "sha1"3445 name = "sha1"
3423 version = "0.10.7"3446 version = "0.10.7"
@@ -3521,12 +3544,12 @@ dependencies = [
3521 3544
3522 [[package]]3545 [[package]]
3523 name = "signature"3546 name = "signature"
3524-version = "2.2.0"3547+version = "3.0.0"
3525 source = "registry+https://github.com/rust-lang/crates.io-index"3548 source = "registry+https://github.com/rust-lang/crates.io-index"
3526-checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"3549+checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5"
3527 dependencies = [3550 dependencies = [
3528- "digest 0.10.7",3551+ "digest 0.11.3",
3529- "rand_core 0.6.4",3552+ "rand_core 0.10.1",
3530 ]3553 ]
3531 3554
3532 [[package]]3555 [[package]]
@@ -3611,9 +3634,9 @@ checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"
3611 3634
3612 [[package]]3635 [[package]]
3613 name = "spki"3636 name = "spki"
3614-version = "0.7.3"3637+version = "0.8.0"
3615 source = "registry+https://github.com/rust-lang/crates.io-index"3638 source = "registry+https://github.com/rust-lang/crates.io-index"
3616-checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"3639+checksum = "1d9efca8738c78ee9484207732f728b1ef517bbb1833d6fc0879ca898a522f6f"
3617 dependencies = [3640 dependencies = [
3618 "base64ct",3641 "base64ct",
3619 "der",3642 "der",
@@ -4076,14 +4099,13 @@ checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
4076 4099
4077 [[package]]4100 [[package]]
4078 name = "topcoat"4101 name = "topcoat"
4079-version = "0.6.2"4102+version = "0.8.0"
4080 source = "registry+https://github.com/rust-lang/crates.io-index"4103 source = "registry+https://github.com/rust-lang/crates.io-index"
4081-checksum = "050c11e7b0e146a2b1eb15855abd5fa03e2754eb880922f8b6cab5ec71cac5aa"4104+checksum = "f3c199295b1c52e0a9c88a2b0518f6bc7522503cd0bb06d9f4742c515ac4df0a"
4082 dependencies = [4105 dependencies = [
4083 "futures-util",4106 "futures-util",
4084 "inventory",4107 "inventory",
4085 "serde",4108 "serde",
4086- "serde_urlencoded",
4087 "tokio",4109 "tokio",
4088 "tokio-tungstenite",4110 "tokio-tungstenite",
4089 "topcoat-asset",4111 "topcoat-asset",
@@ -4104,9 +4126,9 @@ dependencies = [
4104 4126
4105 [[package]]4127 [[package]]
4106 name = "topcoat-asset"4128 name = "topcoat-asset"
4107-version = "0.6.2"4129+version = "0.8.0"
4108 source = "registry+https://github.com/rust-lang/crates.io-index"4130 source = "registry+https://github.com/rust-lang/crates.io-index"
4109-checksum = "a72e4ba8cb6a9d29613a25c2151e72d887b4a79b3f179b497734eed0e65ea702"4131+checksum = "fba199ae779d0409672929e7c32711ac35e87c9e39e0823d0b33b6293e3e0011"
4110 dependencies = [4132 dependencies = [
4111 "http",4133 "http",
4112 "memchr",4134 "memchr",
@@ -4122,9 +4144,9 @@ dependencies = [
4122 4144
4123 [[package]]4145 [[package]]
4124 name = "topcoat-cookie"4146 name = "topcoat-cookie"
4125-version = "0.6.2"4147+version = "0.8.0"
4126 source = "registry+https://github.com/rust-lang/crates.io-index"4148 source = "registry+https://github.com/rust-lang/crates.io-index"
4127-checksum = "f68c83654c4bf075f667d39463cd38ef0be9fee057054454b06612efe16e7a37"4149+checksum = "3cb0bf2f95c1931d32d579389695e8cf221d114f9629a57fc005d7a0bb459c0d"
4128 dependencies = [4150 dependencies = [
4129 "cookie",4151 "cookie",
4130 "getrandom 0.2.17",4152 "getrandom 0.2.17",
@@ -4137,9 +4159,9 @@ dependencies = [
4137 4159
4138 [[package]]4160 [[package]]
4139 name = "topcoat-core"4161 name = "topcoat-core"
4140-version = "0.6.2"4162+version = "0.8.0"
4141 source = "registry+https://github.com/rust-lang/crates.io-index"4163 source = "registry+https://github.com/rust-lang/crates.io-index"
4142-checksum = "42f94adaa301d7a4b949d650fa803323c00cc8ffa8bf1984511c1ec5d390b6c6"4164+checksum = "d88c5ed693dd383ba8a4112f5b665bdb7e979ada413a7b5f9ede6935fe18e8e6"
4143 dependencies = [4165 dependencies = [
4144 "anyhow",4166 "anyhow",
4145 "anymap3",4167 "anymap3",
@@ -4153,9 +4175,9 @@ dependencies = [
4153 4175
4154 [[package]]4176 [[package]]
4155 name = "topcoat-core-grammar"4177 name = "topcoat-core-grammar"
4156-version = "0.6.2"4178+version = "0.8.0"
4157 source = "registry+https://github.com/rust-lang/crates.io-index"4179 source = "registry+https://github.com/rust-lang/crates.io-index"
4158-checksum = "0756aa9285794c155624494bc563d56859e35205313db883a89d7dabfa6d0393"4180+checksum = "ce257f5c2248b4d7bf1bbd76a0e71709221f06d690462a49aad5929732c42001"
4159 dependencies = [4181 dependencies = [
4160 "proc-macro-crate",4182 "proc-macro-crate",
4161 "proc-macro2",4183 "proc-macro2",
@@ -4165,9 +4187,9 @@ dependencies = [
4165 4187
4166 [[package]]4188 [[package]]
4167 name = "topcoat-core-macro"4189 name = "topcoat-core-macro"
4168-version = "0.6.2"4190+version = "0.8.0"
4169 source = "registry+https://github.com/rust-lang/crates.io-index"4191 source = "registry+https://github.com/rust-lang/crates.io-index"
4170-checksum = "e4908dba6268c8592be73e9059cdefa053066e1b1bc879c1c9a5d8d3b6e97aad"4192+checksum = "5d239098a8c674f16120e7bfcba6f670865c807eec2a0e2648cb319d300fab39"
4171 dependencies = [4193 dependencies = [
4172 "quote",4194 "quote",
4173 "syn 2.0.119",4195 "syn 2.0.119",
@@ -4176,9 +4198,9 @@ dependencies = [
4176 4198
4177 [[package]]4199 [[package]]
4178 name = "topcoat-font"4200 name = "topcoat-font"
4179-version = "0.6.2"4201+version = "0.8.0"
4180 source = "registry+https://github.com/rust-lang/crates.io-index"4202 source = "registry+https://github.com/rust-lang/crates.io-index"
4181-checksum = "e7b8308aff65f46bbe2f58371fc9823db596236bd0ea3c9d87de6534fd977e60"4203+checksum = "8ccc2da492bfdcf2d23d761b60338eb20ad178fd754ef19570abe6030663137d"
4182 dependencies = [4204 dependencies = [
4183 "heck",4205 "heck",
4184 "inventory",4206 "inventory",
@@ -4193,9 +4215,9 @@ dependencies = [
4193 4215
4194 [[package]]4216 [[package]]
4195 name = "topcoat-font-grammar"4217 name = "topcoat-font-grammar"
4196-version = "0.6.2"4218+version = "0.8.0"
4197 source = "registry+https://github.com/rust-lang/crates.io-index"4219 source = "registry+https://github.com/rust-lang/crates.io-index"
4198-checksum = "5b7d68e226827fb7531d0dba69cb74fa7b82515f8428fd1a75f556f5a2bf87c1"4220+checksum = "6125e270bb16bf826a54e4b40b41484682b2b660af4803688887f64a9918745a"
4199 dependencies = [4221 dependencies = [
4200 "proc-macro2",4222 "proc-macro2",
4201 "quote",4223 "quote",
@@ -4206,9 +4228,9 @@ dependencies = [
4206 4228
4207 [[package]]4229 [[package]]
4208 name = "topcoat-font-macro"4230 name = "topcoat-font-macro"
4209-version = "0.6.2"4231+version = "0.8.0"
4210 source = "registry+https://github.com/rust-lang/crates.io-index"4232 source = "registry+https://github.com/rust-lang/crates.io-index"
4211-checksum = "e655c430bcb380f879603ea750c6222ade2ff3ade33869d9eaa32e3fc49f5469"4233+checksum = "5f46d0a9c08e7bf774683c05add490824af80a844f410e6ffc9fdaf00c88d7be"
4212 dependencies = [4234 dependencies = [
4213 "quote",4235 "quote",
4214 "syn 2.0.119",4236 "syn 2.0.119",
@@ -4217,9 +4239,9 @@ dependencies = [
4217 4239
4218 [[package]]4240 [[package]]
4219 name = "topcoat-mail"4241 name = "topcoat-mail"
4220-version = "0.6.2"4242+version = "0.8.0"
4221 source = "registry+https://github.com/rust-lang/crates.io-index"4243 source = "registry+https://github.com/rust-lang/crates.io-index"
4222-checksum = "959c9c32172ad3840f94c589a29bd143c072661c9abf2215a68fd76440ed2300"4244+checksum = "1b8fa0e1ad5a4f4419c50b783ac565426df5c30dfa3dc9ca9602c8cd1c3535a3"
4223 dependencies = [4245 dependencies = [
4224 "lettre",4246 "lettre",
4225 "thiserror",4247 "thiserror",
@@ -4231,9 +4253,9 @@ dependencies = [
4231 4253
4232 [[package]]4254 [[package]]
4233 name = "topcoat-router"4255 name = "topcoat-router"
4234-version = "0.6.2"4256+version = "0.8.0"
4235 source = "registry+https://github.com/rust-lang/crates.io-index"4257 source = "registry+https://github.com/rust-lang/crates.io-index"
4236-checksum = "e062bd348df5647f6904f4f4045b3c92c08c4a8826196e8e91a51aade00b5764"4258+checksum = "9f452945373fac2b61a4050639681829e99afeea872faebc93ef0b03c4211335"
4237 dependencies = [4259 dependencies = [
4238 "bytes",4260 "bytes",
4239 "form_urlencoded",4261 "form_urlencoded",
@@ -4249,6 +4271,7 @@ dependencies = [
4249 "matchit",4271 "matchit",
4250 "multer",4272 "multer",
4251 "percent-encoding",4273 "percent-encoding",
4274+ "pin-project-lite",
4252 "ref-cast",4275 "ref-cast",
4253 "serde",4276 "serde",
4254 "serde_json",4277 "serde_json",
@@ -4263,9 +4286,9 @@ dependencies = [
4263 4286
4264 [[package]]4287 [[package]]
4265 name = "topcoat-router-grammar"4288 name = "topcoat-router-grammar"
4266-version = "0.6.2"4289+version = "0.8.0"
4267 source = "registry+https://github.com/rust-lang/crates.io-index"4290 source = "registry+https://github.com/rust-lang/crates.io-index"
4268-checksum = "c052423d2aa4039036f1ac5567d1e2dac48897602d34561b3024a87830e5bdce"4291+checksum = "188df45ec401d790e3dd84564580c5c436a456331a187bdbfb7441f8e48fa1ca"
4269 dependencies = [4292 dependencies = [
4270 "heck",4293 "heck",
4271 "proc-macro2",4294 "proc-macro2",
@@ -4276,9 +4299,9 @@ dependencies = [
4276 4299
4277 [[package]]4300 [[package]]
4278 name = "topcoat-router-macro"4301 name = "topcoat-router-macro"
4279-version = "0.6.2"4302+version = "0.8.0"
4280 source = "registry+https://github.com/rust-lang/crates.io-index"4303 source = "registry+https://github.com/rust-lang/crates.io-index"
4281-checksum = "cea98692b786bab3adda35a60d71981f60b2a98c6e7105ac92e582b7c9ce9cab"4304+checksum = "ac6f9a61d3ecfe1252b861795070c4317aca6b816382919d9c941eccad2fe42d"
4282 dependencies = [4305 dependencies = [
4283 "quote",4306 "quote",
4284 "syn 2.0.119",4307 "syn 2.0.119",
@@ -4287,9 +4310,9 @@ dependencies = [
4287 4310
4288 [[package]]4311 [[package]]
4289 name = "topcoat-runtime"4312 name = "topcoat-runtime"
4290-version = "0.6.2"4313+version = "0.8.0"
4291 source = "registry+https://github.com/rust-lang/crates.io-index"4314 source = "registry+https://github.com/rust-lang/crates.io-index"
4292-checksum = "5dea200c86ca554bab7410f09cae8790a8adcbfd8f306eb78db7092ca71f8aae"4315+checksum = "b75367a6fb32878f28bb1e42fe97385c9b14f1d3455b0bb69afb399260a8995a"
4293 dependencies = [4316 dependencies = [
4294 "inventory",4317 "inventory",
4295 "ref-cast",4318 "ref-cast",
@@ -4299,14 +4322,13 @@ dependencies = [
4299 "topcoat-core",4322 "topcoat-core",
4300 "topcoat-router",4323 "topcoat-router",
4301 "topcoat-view",4324 "topcoat-view",
4302- "uuid",
4303 ]4325 ]
4304 4326
4305 [[package]]4327 [[package]]
4306 name = "topcoat-runtime-grammar"4328 name = "topcoat-runtime-grammar"
4307-version = "0.6.2"4329+version = "0.8.0"
4308 source = "registry+https://github.com/rust-lang/crates.io-index"4330 source = "registry+https://github.com/rust-lang/crates.io-index"
4309-checksum = "87b73f7e4e10f49e006a71dd43e8ee629c76c08451acbc51faa7ec5b6952c53c"4331+checksum = "c19d5cf0ad59525a9fdd0a6ada36448833b39b85602736df16d32712f6c3a3c8"
4310 dependencies = [4332 dependencies = [
4311 "proc-macro2",4333 "proc-macro2",
4312 "quote",4334 "quote",
@@ -4320,9 +4342,9 @@ dependencies = [
4320 4342
4321 [[package]]4343 [[package]]
4322 name = "topcoat-runtime-macro"4344 name = "topcoat-runtime-macro"
4323-version = "0.6.2"4345+version = "0.8.0"
4324 source = "registry+https://github.com/rust-lang/crates.io-index"4346 source = "registry+https://github.com/rust-lang/crates.io-index"
4325-checksum = "5dc3e4e245abcaea6af780437cae072e8f2157c9852ec5b3058a658c61b9e0bf"4347+checksum = "3504cd2966788c4cb6f417a9f73faf3ae2631c5aa415bc0d37d142ba597d5c42"
4326 dependencies = [4348 dependencies = [
4327 "quote",4349 "quote",
4328 "syn 2.0.119",4350 "syn 2.0.119",
@@ -4331,9 +4353,9 @@ dependencies = [
4331 4353
4332 [[package]]4354 [[package]]
4333 name = "topcoat-session"4355 name = "topcoat-session"
4334-version = "0.6.2"4356+version = "0.8.0"
4335 source = "registry+https://github.com/rust-lang/crates.io-index"4357 source = "registry+https://github.com/rust-lang/crates.io-index"
4336-checksum = "e079e8c5a63987d7f929ab05a75922feab1fe390a9cfa2c101eb35829e67eac2"4358+checksum = "d432a276f3d7e4e0af0f9789ee0c919fbfbf8d2025d0dac7f8072a918521cf6d"
4337 dependencies = [4359 dependencies = [
4338 "base64 0.22.1",4360 "base64 0.22.1",
4339 "getrandom 0.4.3",4361 "getrandom 0.4.3",
@@ -4348,25 +4370,26 @@ dependencies = [
4348 4370
4349 [[package]]4371 [[package]]
4350 name = "topcoat-view"4372 name = "topcoat-view"
4351-version = "0.6.2"4373+version = "0.8.0"
4352 source = "registry+https://github.com/rust-lang/crates.io-index"4374 source = "registry+https://github.com/rust-lang/crates.io-index"
4353-checksum = "5904449bd6f633759d187fa621ded68178b551428c297959fd53d8fb91f3e6f6"4375+checksum = "4acc959c83729cb4b967c2e7de8ee78a2fc3216cceb1be650ee9524fabd26baa"
4354 dependencies = [4376 dependencies = [
4377+ "base64 0.22.1",
4355 "futures-core",4378 "futures-core",
4356 "futures-util",4379 "futures-util",
4357 "http",4380 "http",
4358- "itoa",
4359 "memchr",4381 "memchr",
4360 "pin-project-lite",4382 "pin-project-lite",
4383+ "siphasher",
4361 "smallvec",4384 "smallvec",
4362 "topcoat-core",4385 "topcoat-core",
4363 ]4386 ]
4364 4387
4365 [[package]]4388 [[package]]
4366 name = "topcoat-view-grammar"4389 name = "topcoat-view-grammar"
4367-version = "0.6.2"4390+version = "0.8.0"
4368 source = "registry+https://github.com/rust-lang/crates.io-index"4391 source = "registry+https://github.com/rust-lang/crates.io-index"
4369-checksum = "1bf4293156d7c5fa7960edc573b686eb27426dcd888bfbe9e532304178cdda24"4392+checksum = "fa71393a00dba3ce203d3236e24311851134721f5bfae6a17bfacd709a983660"
4370 dependencies = [4393 dependencies = [
4371 "heck",4394 "heck",
4372 "proc-macro2",4395 "proc-macro2",
@@ -4378,9 +4401,9 @@ dependencies = [
4378 4401
4379 [[package]]4402 [[package]]
4380 name = "topcoat-view-macro"4403 name = "topcoat-view-macro"
4381-version = "0.6.2"4404+version = "0.8.0"
4382 source = "registry+https://github.com/rust-lang/crates.io-index"4405 source = "registry+https://github.com/rust-lang/crates.io-index"
4383-checksum = "58ab2b200eda4516abdb543f307006d83fedd3681b871d2042c17106c688f716"4406+checksum = "2a625be243364f6674204ba412700d9eed2a1c9168f7add3b1020be4825f0e49"
4384 dependencies = [4407 dependencies = [
4385 "quote",4408 "quote",
4386 "syn 2.0.119",4409 "syn 2.0.119",
@@ -4792,11 +4815,11 @@ dependencies = [
4792 4815
4793 [[package]]4816 [[package]]
4794 name = "ulid"4817 name = "ulid"
4795-version = "1.2.1"4818+version = "3.0.0"
4796 source = "registry+https://github.com/rust-lang/crates.io-index"4819 source = "registry+https://github.com/rust-lang/crates.io-index"
4797-checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe"4820+checksum = "947dde63b6d514cc5e044edad4e0ca7261afd1099d16c83d942cb2b2f348689c"
4798 dependencies = [4821 dependencies = [
4799- "rand 0.9.5",4822+ "rand 0.10.2",
4800 "web-time",4823 "web-time",
4801 ]4824 ]
4802 4825
@@ -4831,6 +4854,16 @@ dependencies = [
4831 "subtle",4854 "subtle",
4832 ]4855 ]
4833 4856
4857+[[package]]
4858+name = "universal-hash"
4859+version = "0.6.1"
4860+source = "registry+https://github.com/rust-lang/crates.io-index"
4861+checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96"
4862+dependencies = [
4863+ "crypto-common 0.2.2",
4864+ "ctutils",
4865+]
4866+
4834 [[package]]4867 [[package]]
4835 name = "untrusted"4868 name = "untrusted"
4836 version = "0.9.0"4869 version = "0.9.0"
Cargo.tomlmodified+3 -3
@@ -18,7 +18,7 @@ im-core = { path = "crates/im-core", default-features = false }
18 serde = { version = "1.0.229", features = ["derive"] }18 serde = { version = "1.0.229", features = ["derive"] }
19 serde_json = "1.0.151"19 serde_json = "1.0.151"
20 thiserror = "2.0.20"20 thiserror = "2.0.20"
21-ulid = "1"21+ulid = "3"
22 time = { version = "0.3.55", features = ["serde", "formatting", "parsing", "macros"] }22 time = { version = "0.3.55", features = ["serde", "formatting", "parsing", "macros"] }
23 tokio = { version = "1.53.1", features = ["full"] }23 tokio = { version = "1.53.1", features = ["full"] }
24 turso = "=0.8.0-pre.10"24 turso = "=0.8.0-pre.10"
@@ -26,8 +26,8 @@ argon2 = "0.6.0"
26 rand = "0.10.2"26 rand = "0.10.2"
27 sha2 = "0.11.0"27 sha2 = "0.11.0"
28 subtle = "2.6.1"28 subtle = "2.6.1"
29-chacha20poly1305 = "0.10.1"29+chacha20poly1305 = "0.11.0"
30-base64 = "0.22.1"30+base64 = "0.23.1"
31 toml = "1"31 toml = "1"
32 async-trait = "0.1.92"32 async-trait = "0.1.92"
33 33
crates/im-client/Cargo.tomlmodified+8 -9
@@ -15,7 +15,7 @@ default = ["oidc"]
15 oidc = []15 oidc = []
16 16
17 [dependencies]17 [dependencies]
18-topcoat = { version = "0.6.2", default-features = false, features = [18+topcoat = { version = "0.8.0", default-features = false, features = [
19 "router",19 "router",
20 "cookie",20 "cookie",
21 ] }21 ] }
@@ -29,10 +29,9 @@ rand.workspace = true
29 sha2.workspace = true29 sha2.workspace = true
30 subtle.workspace = true30 subtle.workspace = true
31 chacha20poly1305.workspace = true31 chacha20poly1305.workspace = true
32-# rsa 0.9 verifies through the digest 0.10 traits, so its hasher comes from32+# rsa 0.10 verifies through the digest 0.11 traits, so its hasher is the
33-# the sha2 0.10 line; the workspace sha2 0.11 stays for PKCE.33+# workspace sha2 0.11 that PKCE already uses.
34-sha2-for-rsa = { package = "sha2", version = "0.10", features = ["oid"] }34+rsa = "0.10.0-rc.18"
35-rsa = "0.9.10"
36 reqwest = { version = "0.13.5", default-features = false, features = [35 reqwest = { version = "0.13.5", default-features = false, features = [
37 "rustls",36 "rustls",
38 "json",37 "json",
@@ -46,7 +45,7 @@ name = "demo"
46 required-features = ["oidc"]45 required-features = ["oidc"]
47 46
48 [dev-dependencies]47 [dev-dependencies]
49-topcoat = { version = "0.6.2", default-features = false, features = [48+topcoat = { version = "0.8.0", default-features = false, features = [
50 "router",49 "router",
51 "cookie",50 "cookie",
52 "view",51 "view",
@@ -54,6 +53,6 @@ topcoat = { version = "0.6.2", default-features = false, features = [
54 "discover",53 "discover",
55 ] }54 ] }
56 http = "1.5"55 http = "1.5"
57-# Tests generate their own RSA keys, and rsa 0.9's RNG is the rand_core 0.656+# Tests generate their own RSA keys, and rsa 0.10's RNG is the rand_core 0.10
58-# line.57+# line that the workspace rand 0.10 provides.
59-rand_core06 = { package = "rand_core", version = "0.6.4", features = ["getrandom"] }58+rand_core010 = { package = "rand_core", version = "0.10.1" }
crates/im-client/src/directory.rsmodified+4 -4
@@ -257,10 +257,10 @@ impl SseParser {
257 fn take_event(&mut self) -> Option<DirectoryEvent> {257 fn take_event(&mut self) -> Option<DirectoryEvent> {
258 let data = std::mem::take(&mut self.data);258 let data = std::mem::take(&mut self.data);
259 let event = self.event.take();259 let event = self.event.take();
260- if let Some(kind) = event {260+ if let Some(kind) = event
261- if kind != "profile" {261+ && kind != "profile"
262- return None;262+ {
263- }263+ return None;
264 }264 }
265 serde_json::from_str::<DirectoryMember>(&data)265 serde_json::from_str::<DirectoryMember>(&data)
266 .ok()266 .ok()
crates/im-client/src/oidc.rsmodified+10 -10
@@ -178,8 +178,9 @@ fn seal(key: &[u8; 32], plaintext: &[u8]) -> String {
178 let cipher = XChaCha20Poly1305::new(key.into());178 let cipher = XChaCha20Poly1305::new(key.into());
179 let mut nonce_bytes = [0u8; 24];179 let mut nonce_bytes = [0u8; 24];
180 rand::rng().fill_bytes(&mut nonce_bytes);180 rand::rng().fill_bytes(&mut nonce_bytes);
181+ let nonce = XNonce::from(nonce_bytes);
181 let ciphertext = cipher182 let ciphertext = cipher
182- .encrypt(XNonce::from_slice(&nonce_bytes), plaintext)183+ .encrypt(&nonce, plaintext)
183 .expect("XChaCha20-Poly1305 cannot fail on a payload this small");184 .expect("XChaCha20-Poly1305 cannot fail on a payload this small");
184 let mut payload = nonce_bytes.to_vec();185 let mut payload = nonce_bytes.to_vec();
185 payload.extend_from_slice(&ciphertext);186 payload.extend_from_slice(&ciphertext);
@@ -193,9 +194,8 @@ fn open(key: &[u8; 32], sealed: &str) -> Option<Vec<u8>> {
193 }194 }
194 let (nonce_bytes, ciphertext) = payload.split_at(24);195 let (nonce_bytes, ciphertext) = payload.split_at(24);
195 let cipher = XChaCha20Poly1305::new(key.into());196 let cipher = XChaCha20Poly1305::new(key.into());
196- cipher197+ let nonce: &XNonce = nonce_bytes.try_into().ok()?;
197- .decrypt(XNonce::from_slice(nonce_bytes), ciphertext)198+ cipher.decrypt(nonce, ciphertext).ok()
198- .ok()
199 }199 }
200 200
201 fn seal_json<T: Serialize>(key: &[u8; 32], value: &T) -> String {201 fn seal_json<T: Serialize>(key: &[u8; 32], value: &T) -> String {
@@ -514,7 +514,7 @@ fn verify_claims(
514 .map_err(|e| Error::Token(e.to_string()))?;514 .map_err(|e| Error::Token(e.to_string()))?;
515 let signature = rsa::pkcs1v15::Signature::try_from(signature_bytes.as_slice())515 let signature = rsa::pkcs1v15::Signature::try_from(signature_bytes.as_slice())
516 .map_err(|e| Error::Token(e.to_string()))?;516 .map_err(|e| Error::Token(e.to_string()))?;
517- let verifying = rsa::pkcs1v15::VerifyingKey::<sha2_for_rsa::Sha256>::new(key.clone());517+ let verifying = rsa::pkcs1v15::VerifyingKey::<sha2::Sha256>::new(key.clone());
518 verifying518 verifying
519 .verify(format!("{}.{}", parts[0], parts[1]).as_bytes(), &signature)519 .verify(format!("{}.{}", parts[0], parts[1]).as_bytes(), &signature)
520 .map_err(|_| Error::Token("bad signature".into()))?;520 .map_err(|_| Error::Token("bad signature".into()))?;
@@ -575,8 +575,8 @@ async fn refetch_jwks(state: &ImClient) -> Result<()> {
575 continue;575 continue;
576 };576 };
577 let key = rsa::RsaPublicKey::new(577 let key = rsa::RsaPublicKey::new(
578- rsa::BigUint::from_bytes_be(&n),578+ rsa::BoxedUint::from_be_slice_vartime(&n),
579- rsa::BigUint::from_bytes_be(&e),579+ rsa::BoxedUint::from_be_slice_vartime(&e),
580 )580 )
581 .map_err(|err| Error::Token(format!("bad jwk {kid}: {err}")))?;581 .map_err(|err| Error::Token(format!("bad jwk {kid}: {err}")))?;
582 keys.push((kid.to_string(), key));582 keys.push((kid.to_string(), key));
@@ -595,8 +595,8 @@ mod tests {
595 595
596 fn keypair() -> (rsa::RsaPrivateKey, rsa::RsaPublicKey) {596 fn keypair() -> (rsa::RsaPrivateKey, rsa::RsaPublicKey) {
597 // 2048-bit generation is slow for a unit test; 1024 is the smallest597 // 2048-bit generation is slow for a unit test; 1024 is the smallest
598- // rsa 0.9 accepts and the signature math under test is identical.598+ // rsa accepts and the signature math under test is identical.
599- let private = rsa::RsaPrivateKey::new(&mut rand_core06::OsRng, 1024).unwrap();599+ let private = rsa::RsaPrivateKey::new(&mut rand::rng(), 1024).unwrap();
600 let public = private.to_public_key();600 let public = private.to_public_key();
601 (private, public)601 (private, public)
602 }602 }
@@ -606,7 +606,7 @@ mod tests {
606 let mut out = b64url.encode(header.to_string());606 let mut out = b64url.encode(header.to_string());
607 out.push('.');607 out.push('.');
608 out.push_str(&b64url.encode(claims.to_string()));608 out.push_str(&b64url.encode(claims.to_string()));
609- let signing = rsa::pkcs1v15::SigningKey::<sha2_for_rsa::Sha256>::new(key.clone());609+ let signing = rsa::pkcs1v15::SigningKey::<sha2::Sha256>::new(key.clone());
610 let signature = signing.sign(out.as_bytes());610 let signature = signing.sign(out.as_bytes());
611 format!("{}.{}", out, b64url.encode(signature.to_bytes()))611 format!("{}.{}", out, b64url.encode(signature.to_bytes()))
612 }612 }
crates/im-core/Cargo.tomlmodified+4 -7
@@ -22,7 +22,6 @@ server = [
22 "dep:rsa",22 "dep:rsa",
23 "dep:sha1",23 "dep:sha1",
24 "dep:sha2",24 "dep:sha2",
25- "dep:sha2-for-rsa",
26 "dep:subtle",25 "dep:subtle",
27 "dep:tokio",26 "dep:tokio",
28 "dep:turso",27 "dep:turso",
@@ -36,14 +35,12 @@ chacha20poly1305 = { workspace = true, optional = true }
36 data-encoding = { version = "2.11.1", optional = true }35 data-encoding = { version = "2.11.1", optional = true }
37 hmac = { version = "0.13.0", optional = true }36 hmac = { version = "0.13.0", optional = true }
38 rand = { workspace = true, optional = true }37 rand = { workspace = true, optional = true }
39-# rsa 0.9 sits on the rand_core 0.6 / digest 0.10 trait lines, so its RNG38+# rsa 0.10 sits on the rand_core 0.10 / digest 0.11 trait lines, so its RNG
40-# and its hasher come from those lines, not the workspace's rand 0.10 /39+# and its hasher come from those lines: the workspace rand 0.10 / sha2 0.11.
41-# sha2 0.11. sha2 0.11 stays for token digests.40+rand_core = { version = "0.10.1", optional = true }
42-rand_core = { version = "0.6.4", features = ["getrandom"], optional = true }41+rsa = { version = "0.10.0-rc.18", optional = true }
43-rsa = { version = "0.9.10", optional = true }
44 sha1 = { version = "0.11.0", optional = true }42 sha1 = { version = "0.11.0", optional = true }
45 sha2 = { workspace = true, optional = true }43 sha2 = { workspace = true, optional = true }
46-sha2-for-rsa = { package = "sha2", version = "0.10", features = ["oid"], optional = true }
47 subtle = { workspace = true, optional = true }44 subtle = { workspace = true, optional = true }
48 serde.workspace = true45 serde.workspace = true
49 serde_json.workspace = true46 serde_json.workspace = true
crates/im-core/src/accounts.rsmodified+19 -19
@@ -909,10 +909,10 @@ fn normalize_email(email: &str) -> std::result::Result<String, AccountError> {
909 /// address the account already carries quietly succeeds.909 /// address the account already carries quietly succeeds.
910 pub async fn set_email(store: &Store, user: &UserId, email: &str) -> std::result::Result<(), AccountError> {910 pub async fn set_email(store: &Store, user: &UserId, email: &str) -> std::result::Result<(), AccountError> {
911 let email = normalize_email(email)?;911 let email = normalize_email(email)?;
912- if let Some(other) = user_by_email(store, &email).await? {912+ if let Some(other) = user_by_email(store, &email).await?
913- if other.id != *user {913+ && other.id != *user
914- return Err(AccountError::EmailTaken);914+ {
915- }915+ return Err(AccountError::EmailTaken);
916 }916 }
917 let conn = store.conn.lock().await;917 let conn = store.conn.lock().await;
918 conn.execute(918 conn.execute(
@@ -953,10 +953,10 @@ pub async fn request_email_change(
953 if new_email == old_email {953 if new_email == old_email {
954 return Err(AccountError::SameEmail);954 return Err(AccountError::SameEmail);
955 }955 }
956- if let Some(other) = user_by_email(store, &new_email).await? {956+ if let Some(other) = user_by_email(store, &new_email).await?
957- if other.id != *user {957+ && other.id != *user
958- return Err(AccountError::EmailTaken);958+ {
959- }959+ return Err(AccountError::EmailTaken);
960 }960 }
961 let old_token = Token::mint();961 let old_token = Token::mint();
962 let new_token = Token::mint();962 let new_token = Token::mint();
@@ -1040,17 +1040,17 @@ pub async fn confirm_email_change(
1040 }1040 }
1041 let completes = (clicked_old && new_done) || (!clicked_old && old_done);1041 let completes = (clicked_old && new_done) || (!clicked_old && old_done);
1042 if completes {1042 if completes {
1043- if let Some(other) = user_by_email(store, &new_email).await? {1043+ if let Some(other) = user_by_email(store, &new_email).await?
1044- if other.id != user_id {1044+ && other.id != user_id
1045- let conn = store.conn.lock().await;1045+ {
1046- conn.execute(1046+ let conn = store.conn.lock().await;
1047- "DELETE FROM email_changes WHERE old_token_hash = ?1 OR new_token_hash = ?1",1047+ conn.execute(
1048- turso::params![hash],1048+ "DELETE FROM email_changes WHERE old_token_hash = ?1 OR new_token_hash = ?1",
1049- )1049+ turso::params![hash],
1050- .await1050+ )
1051- .map_err(backend)?;1051+ .await
1052- return Err(AccountError::EmailTaken);1052+ .map_err(backend)?;
1053- }1053+ return Err(AccountError::EmailTaken);
1054 }1054 }
1055 set_email(store, &user_id, &new_email).await?;1055 set_email(store, &user_id, &new_email).await?;
1056 let stamp = store::stamp(store::now())?;1056 let stamp = store::stamp(store::now())?;
crates/im-core/src/events.rsmodified+1 -1
@@ -22,7 +22,7 @@ pub async fn log(store: &Store, kind: &str, actor: Option<&str>, detail: Option<
22 .execute(22 .execute(
23 "INSERT INTO events (id, at, kind, actor, detail) VALUES (?1, ?2, ?3, ?4, ?5)",23 "INSERT INTO events (id, at, kind, actor, detail) VALUES (?1, ?2, ?3, ?4, ?5)",
24 turso::params![24 turso::params![
25- ulid::Ulid::new().to_string(),25+ ulid::Ulid::generate().to_string(),
26 store::stamp(store::now()).expect("rfc3339 of now"),26 store::stamp(store::now()).expect("rfc3339 of now"),
27 kind,27 kind,
28 actor,28 actor,
crates/im-core/src/keys.rsmodified+4 -3
@@ -5,6 +5,7 @@
5 //! XChaCha20-Poly1305 envelope of its PKCS#8 DER under `im.key`, and only5 //! XChaCha20-Poly1305 envelope of its PKCS#8 DER under `im.key`, and only
6 //! `active_signing_key` (signing) and `jwks` (the public half) cross the6 //! `active_signing_key` (signing) and `jwks` (the public half) cross the
7 //! boundary.7 //! boundary.
8+use rand::SeedableRng as _;
8 use rsa::pkcs8::{DecodePrivateKey, DecodePublicKey, EncodePrivateKey, EncodePublicKey};9 use rsa::pkcs8::{DecodePrivateKey, DecodePublicKey, EncodePrivateKey, EncodePublicKey};
9 use rsa::traits::PublicKeyParts;10 use rsa::traits::PublicKeyParts;
10 use rsa::{RsaPrivateKey, RsaPublicKey};11 use rsa::{RsaPrivateKey, RsaPublicKey};
@@ -38,7 +39,7 @@ pub async fn active_signing_key(store: &Store) -> Result<(String, RsaPrivateKey)
38 return Ok((kid, key));39 return Ok((kid, key));
39 }40 }
40 41
41- let mut rng = rand_core::OsRng;42+ let mut rng = rand::rngs::StdRng::from_rng(&mut rand::rng());
42 let key = RsaPrivateKey::new(&mut rng, 2048)43 let key = RsaPrivateKey::new(&mut rng, 2048)
43 .map_err(|e| StoreError::Backend(format!("key generation: {e}")))?;44 .map_err(|e| StoreError::Backend(format!("key generation: {e}")))?;
44 let public_der = key45 let public_der = key
@@ -96,8 +97,8 @@ pub async fn jwks(store: &Store) -> Result<serde_json::Value> {
96 "use": "sig",97 "use": "sig",
97 "alg": "RS256",98 "alg": "RS256",
98 "kid": kid,99 "kid": kid,
99- "n": b64.encode(public.n().to_bytes_be()),100+ "n": b64.encode(public.n().to_be_bytes_trimmed_vartime()),
100- "e": b64.encode(public.e().to_bytes_be()),101+ "e": b64.encode(public.e().to_be_bytes_trimmed_vartime()),
101 }));102 }));
102 }103 }
103 Ok(serde_json::json!({ "keys": keys }))104 Ok(serde_json::json!({ "keys": keys }))
crates/im-core/src/model.rsmodified+1 -1
@@ -23,7 +23,7 @@ macro_rules! id_wrapper {
23 /// A fresh ULID — sortable, URL-safe, unguessable enough for an id.23 /// A fresh ULID — sortable, URL-safe, unguessable enough for an id.
24 #[cfg(feature = "server")]24 #[cfg(feature = "server")]
25 pub fn mint() -> Self {25 pub fn mint() -> Self {
26- Self(ulid::Ulid::new().to_string())26+ Self(ulid::Ulid::generate().to_string())
27 }27 }
28 28
29 pub fn as_str(&self) -> &str {29 pub fn as_str(&self) -> &str {
crates/im-core/src/oidc.rsmodified+5 -7
@@ -43,7 +43,7 @@ pub fn sign_jwt(claims: &serde_json::Value, kid: &str, key: &RsaPrivateKey) -> S
43 let mut out = b64url.encode(header.to_string());43 let mut out = b64url.encode(header.to_string());
44 out.push('.');44 out.push('.');
45 out.push_str(&b64url.encode(claims.to_string()));45 out.push_str(&b64url.encode(claims.to_string()));
46- let signing = rsa::pkcs1v15::SigningKey::<sha2_for_rsa::Sha256>::new(key.clone());46+ let signing = rsa::pkcs1v15::SigningKey::<sha2::Sha256>::new(key.clone());
47 let signature = signing.sign(out.as_bytes());47 let signature = signing.sign(out.as_bytes());
48 out.push('.');48 out.push('.');
49 out.push_str(&b64url.encode(signature.to_bytes()));49 out.push_str(&b64url.encode(signature.to_bytes()));
@@ -474,7 +474,7 @@ pub async fn verify_jwt(
474 let Ok(signature) = rsa::pkcs1v15::Signature::try_from(signature_bytes.as_slice()) else {474 let Ok(signature) = rsa::pkcs1v15::Signature::try_from(signature_bytes.as_slice()) else {
475 return Ok(None);475 return Ok(None);
476 };476 };
477- let verifying = rsa::pkcs1v15::VerifyingKey::<sha2_for_rsa::Sha256>::new(public);477+ let verifying = rsa::pkcs1v15::VerifyingKey::<sha2::Sha256>::new(public);
478 if verifying478 if verifying
479 .verify(format!("{}.{}", parts[0], parts[1]).as_bytes(), &signature)479 .verify(format!("{}.{}", parts[0], parts[1]).as_bytes(), &signature)
480 .is_err()480 .is_err()
@@ -487,10 +487,8 @@ pub async fn verify_jwt(
487 let Ok(claims) = serde_json::from_slice::<serde_json::Value>(&claims_bytes) else {487 let Ok(claims) = serde_json::from_slice::<serde_json::Value>(&claims_bytes) else {
488 return Ok(None);488 return Ok(None);
489 };489 };
490- if let Some(audience) = audience {490+ if let Some(audience) = audience && claims["aud"].as_str() != Some(audience) {
491- if claims["aud"].as_str() != Some(audience) {491+ return Ok(None);
492- return Ok(None);
493- }
494 }492 }
495 let Some(exp) = claims["exp"].as_i64() else {493 let Some(exp) = claims["exp"].as_i64() else {
496 return Ok(None);494 return Ok(None);
@@ -771,7 +769,7 @@ mod tests {
771 assert_eq!(claims["sub"], "u1");769 assert_eq!(claims["sub"], "u1");
772 770
773 let verifying =771 let verifying =
774- rsa::pkcs1v15::VerifyingKey::<sha2_for_rsa::Sha256>::new(key.to_public_key());772+ rsa::pkcs1v15::VerifyingKey::<sha2::Sha256>::new(key.to_public_key());
775 let signature =773 let signature =
776 rsa::pkcs1v15::Signature::try_from(b64url.decode(parts[2]).unwrap().as_slice())774 rsa::pkcs1v15::Signature::try_from(b64url.decode(parts[2]).unwrap().as_slice())
777 .unwrap();775 .unwrap();
crates/im-core/src/photos.rsmodified+2 -2
@@ -26,7 +26,7 @@ fn photo_file(store: &Store, user_id: &str) -> std::path::PathBuf {
26 /// there before intact, never a truncated one under the real name.26 /// there before intact, never a truncated one under the real name.
27 fn write_file_atomic(path: &std::path::Path, bytes: &[u8]) -> std::io::Result<()> {27 fn write_file_atomic(path: &std::path::Path, bytes: &[u8]) -> std::io::Result<()> {
28 use std::io::Write as _;28 use std::io::Write as _;
29- let tmp = path.with_extension(format!("{}.tmp", ulid::Ulid::new()));29+ let tmp = path.with_extension(format!("{}.tmp", ulid::Ulid::generate()));
30 let mut file = std::fs::File::create(&tmp)?;30 let mut file = std::fs::File::create(&tmp)?;
31 file.write_all(bytes)?;31 file.write_all(bytes)?;
32 file.sync_all()?;32 file.sync_all()?;
@@ -42,7 +42,7 @@ pub async fn set_photo(store: &Store, user: &UserId, bytes: &[u8], mime: &str) -
42 // leaves the committed photo exactly as it was, and a crash between42 // leaves the committed photo exactly as it was, and a crash between
43 // commit and rename serves the old bytes next to a staged file the boot43 // commit and rename serves the old bytes next to a staged file the boot
44 // sweep collects — stale, never destroyed.44 // sweep collects — stale, never destroyed.
45- let staged = path.with_extension(format!("incoming-{}", ulid::Ulid::new()));45+ let staged = path.with_extension(format!("incoming-{}", ulid::Ulid::generate()));
46 write_file_atomic(&staged, bytes).map_err(|e| StoreError::Backend(e.to_string()))?;46 write_file_atomic(&staged, bytes).map_err(|e| StoreError::Backend(e.to_string()))?;
47 let written = {47 let written = {
48 let conn = store.conn.lock().await;48 let conn = store.conn.lock().await;
crates/im-core/src/secret.rsmodified+3 -3
@@ -42,9 +42,9 @@ pub fn seal(key: &Key, plaintext: &[u8]) -> String {
42 let cipher = XChaCha20Poly1305::new(key.into());42 let cipher = XChaCha20Poly1305::new(key.into());
43 let mut nonce_bytes = [0u8; NONCE_BYTES];43 let mut nonce_bytes = [0u8; NONCE_BYTES];
44 rand::rng().fill_bytes(&mut nonce_bytes);44 rand::rng().fill_bytes(&mut nonce_bytes);
45- let nonce = XNonce::from_slice(&nonce_bytes);45+ let nonce = XNonce::from(nonce_bytes);
46 let ciphertext = cipher46 let ciphertext = cipher
47- .encrypt(nonce, plaintext)47+ .encrypt(&nonce, plaintext)
48 .expect("XChaCha20-Poly1305 cannot fail to encrypt a plaintext this small");48 .expect("XChaCha20-Poly1305 cannot fail to encrypt a plaintext this small");
49 let mut payload = Vec::with_capacity(NONCE_BYTES + ciphertext.len());49 let mut payload = Vec::with_capacity(NONCE_BYTES + ciphertext.len());
50 payload.extend_from_slice(&nonce_bytes);50 payload.extend_from_slice(&nonce_bytes);
@@ -63,7 +63,7 @@ pub fn open(key: &Key, sealed: &str) -> Option<Vec<u8>> {
63 }63 }
64 let (nonce_bytes, ciphertext) = payload.split_at(NONCE_BYTES);64 let (nonce_bytes, ciphertext) = payload.split_at(NONCE_BYTES);
65 let cipher = XChaCha20Poly1305::new(key.into());65 let cipher = XChaCha20Poly1305::new(key.into());
66- let nonce = XNonce::from_slice(nonce_bytes);66+ let nonce: &XNonce = nonce_bytes.try_into().ok()?;
67 cipher.decrypt(nonce, ciphertext).ok()67 cipher.decrypt(nonce, ciphertext).ok()
68 }68 }
69 69
crates/im-core/src/settings.rsmodified+12 -13
@@ -218,15 +218,15 @@ pub async fn set_smtp(store: &Store, smtp: &Smtp, password: Option<&str>) -> Res
218 set(store, "smtp_username", &smtp.username).await?;218 set(store, "smtp_username", &smtp.username).await?;
219 set(store, "smtp_from", &smtp.from).await?;219 set(store, "smtp_from", &smtp.from).await?;
220 set(store, "smtp_from_name", &smtp.from_name).await?;220 set(store, "smtp_from_name", &smtp.from_name).await?;
221- if let Some(password) = password {221+ if let Some(password) = password
222- if !password.is_empty() {222+ && !password.is_empty()
223- set(223+ {
224- store,224+ set(
225- "smtp_password",225+ store,
226- &secret::seal(store.key(), password.as_bytes()),226+ "smtp_password",
227- )227+ &secret::seal(store.key(), password.as_bytes()),
228- .await?;228+ )
229- }229+ .await?;
230 }230 }
231 Ok(())231 Ok(())
232 }232 }
@@ -480,17 +480,16 @@ mod tests {
480 assert_eq!(policy(&store).await.unwrap().max_sessions, 5);480 assert_eq!(policy(&store).await.unwrap().max_sessions, 5);
481 481
482 // A written value comes back...482 // A written value comes back...
483- let mut value = Policy::default();483+ let value = Policy { max_sessions: 2, ..Policy::default() };
484- value.max_sessions = 2;
485 set_policy(&store, &value).await.unwrap();484 set_policy(&store, &value).await.unwrap();
486 assert_eq!(policy(&store).await.unwrap().max_sessions, 2);485 assert_eq!(policy(&store).await.unwrap().max_sessions, 2);
487 486
488 // ...and zero or negative — a cap that would lock every user out487 // ...and zero or negative — a cap that would lock every user out
489 // of their own account — clamps back to the default, unstored.488 // of their own account — clamps back to the default, unstored.
490- value.max_sessions = 0;489+ let value = Policy { max_sessions: 0, ..Policy::default() };
491 set_policy(&store, &value).await.unwrap();490 set_policy(&store, &value).await.unwrap();
492 assert_eq!(policy(&store).await.unwrap().max_sessions, 5);491 assert_eq!(policy(&store).await.unwrap().max_sessions, 5);
493- value.max_sessions = -3;492+ let value = Policy { max_sessions: -3, ..Policy::default() };
494 set_policy(&store, &value).await.unwrap();493 set_policy(&store, &value).await.unwrap();
495 assert_eq!(policy(&store).await.unwrap().max_sessions, 5);494 assert_eq!(policy(&store).await.unwrap().max_sessions, 5);
496 }495 }
crates/im-core/src/store.rsmodified+1 -1
@@ -351,7 +351,7 @@ impl Store {
351 /// is a fresh tempdir, as throwaway as the database itself.351 /// is a fresh tempdir, as throwaway as the database itself.
352 fn photos_dir(path: &Path) -> std::path::PathBuf {352 fn photos_dir(path: &Path) -> std::path::PathBuf {
353 if path.as_os_str() == ":memory:" {353 if path.as_os_str() == ":memory:" {
354- return std::env::temp_dir().join(format!("im-storage-{}", ulid::Ulid::new()));354+ return std::env::temp_dir().join(format!("im-storage-{}", ulid::Ulid::generate()));
355 }355 }
356 path.parent()356 path.parent()
357 .filter(|d| !d.as_os_str().is_empty())357 .filter(|d| !d.as_os_str().is_empty())
crates/im-migrate/src/main.rsmodified+1 -1
@@ -269,7 +269,7 @@ async fn run(args: &Args) -> Result<Report> {
269 mapping.push_str(&format!("{},{sub}\n", user.id));269 mapping.push_str(&format!("{},{sub}\n", user.id));
270 continue;270 continue;
271 }271 }
272- let sub = ulid::Ulid::new().to_string();272+ let sub = ulid::Ulid::generate().to_string();
273 conn.execute(273 conn.execute(
274 "INSERT INTO users (id, email, name, password_hash, created_at) \274 "INSERT INTO users (id, email, name, password_hash, created_at) \
275 VALUES (?1, ?2, ?3, ?4, ?5)",275 VALUES (?1, ?2, ?3, ?4, ?5)",
crates/im-web/Cargo.tomlmodified+1 -1
@@ -8,7 +8,7 @@ description = "im web app: topcoat UI, OIDC endpoints and the server"
8 build = "build.rs"8 build = "build.rs"
9 9
10 [dependencies]10 [dependencies]
11-topcoat = { version = "0.6.2", default-features = false, features = [11+topcoat = { version = "0.8.0", default-features = false, features = [
12 "router",12 "router",
13 "view",13 "view",
14 "runtime",14 "runtime",
crates/im-web/src/admin.rsmodified+136 -117
@@ -13,7 +13,7 @@ use topcoat::cookie::Cookies;
13 use topcoat::router::content::Form;13 use topcoat::router::content::Form;
14 use topcoat::router::response::{IntoResponse, Response};14 use topcoat::router::response::{IntoResponse, Response};
15 use topcoat::router::{HeaderValue, StatusCode, header, route};15 use topcoat::router::{HeaderValue, StatusCode, header, route};
16-use topcoat::view::view;16+use topcoat::view::{Child, ViewExt, view};
17 17
18 use crate::i18n::{self, Key, lang_of, t};18 use crate::i18n::{self, Key, lang_of, t};
19 use crate::layout::shell;19 use crate::layout::shell;
@@ -26,15 +26,17 @@ fn app(cx: &Cx) -> &App {
26 }26 }
27 27
28 /// The admin behind this request, or the redirect the request gets instead.28 /// The admin behind this request, or the redirect the request gets instead.
29-async fn require_admin(cx: &Cx) -> std::result::Result<User, Response> {29+async fn require_admin(cx: &Cx) -> std::result::Result<User, Box<Response>> {
30 match server::current_user(cx).await {30 match server::current_user(cx).await {
31 Some(user) if user.admin => Ok(user),31 Some(user) if user.admin => Ok(user),
32- _ => Err((32+ _ => Err(Box::new(
33- StatusCode::SEE_OTHER,33+ (
34- [(header::LOCATION, HeaderValue::from_static("/"))],34+ StatusCode::SEE_OTHER,
35- )35+ [(header::LOCATION, HeaderValue::from_static("/"))],
36- .into_response(cx)36+ )
37- .expect("a redirect can always be built")),37+ .into_response(cx)
38+ .expect("a redirect can always be built"),
39+ )),
38 }40 }
39 }41 }
40 42
@@ -49,18 +51,30 @@ fn escape(raw: &str) -> String {
49 51
50 /// One row action as a two-step disclosure — iz's `confirm-details` idiom:52 /// One row action as a two-step disclosure — iz's `confirm-details` idiom:
51 /// the summary is the word ("Delete"), the opened panel says what it costs53 /// the summary is the word ("Delete"), the opened panel says what it costs
52-/// and holds the button that actually does it. Works with no script at all;54+/// and holds the button that actually does it. The eight `&str`s travel as
53-/// the live script adds outside-click closing.55+/// named fields: eight positional parameters tripped the too-many-arguments
54-fn confirm_action(56+/// lint, and the names read better at the call sites anyway.
55- field: &str,57+struct ConfirmAction<'a> {
56- id: &str,58+ field: &'a str,
57- action: &str,59+ id: &'a str,
58- word: &str,60+ action: &'a str,
59- extra_class: &str,61+ word: &'a str,
60- title: &str,62+ extra_class: &'a str,
61- cost: &str,63+ title: &'a str,
62- confirm: &str,64+ cost: &'a str,
63-) -> String {65+ confirm: &'a str,
66+}
67+fn confirm_action(ask: ConfirmAction<'_>) -> String {
68+ let ConfirmAction {
69+ field,
70+ id,
71+ action,
72+ word,
73+ extra_class,
74+ title,
75+ cost,
76+ confirm,
77+ } = ask;
64 format!(78 format!(
65 r#"<details class="admin-confirm"><summary class="admin-action{extra_class}">{word}</summary><div class="admin-confirm-pop"><div class="admin-confirm-title">{title}</div><div class="muted">{cost}</div><form method="post" action="{action}"><input type="hidden" name="{field}" value="{id}"><button class="admin-action{extra_class}" type="submit">{confirm}</button></form></div></details>"#79 r#"<details class="admin-confirm"><summary class="admin-action{extra_class}">{word}</summary><div class="admin-confirm-pop"><div class="admin-confirm-title">{title}</div><div class="muted">{cost}</div><form method="post" action="{action}"><input type="hidden" name="{field}" value="{id}"><button class="admin-action{extra_class}" type="submit">{confirm}</button></form></div></details>"#
66 )80 )
@@ -110,7 +124,7 @@ fn back(cx: &Cx, section: &str, extra: &str) -> Result<Response> {
110 async fn admin_page(cx: &Cx) -> Result<Response> {124 async fn admin_page(cx: &Cx) -> Result<Response> {
111 let me = match require_admin(cx).await {125 let me = match require_admin(cx).await {
112 Ok(me) => me,126 Ok(me) => me,
113- Err(redirect) => return Ok(redirect),127+ Err(redirect) => return Ok(*redirect),
114 };128 };
115 let lang = lang_of(Some(&me));129 let lang = lang_of(Some(&me));
116 let query = topcoat::router::request::uri(cx)130 let query = topcoat::router::request::uri(cx)
@@ -188,6 +202,7 @@ async fn admin_page(cx: &Cx) -> Result<Response> {
188 _ => None,202 _ => None,
189 };203 };
190 204
205+ let my_email = escape(&me.email);
191 let stage = view! {206 let stage = view! {
192 cx =>207 cx =>
193 <main class="admin-shell">208 <main class="admin-shell">
@@ -197,7 +212,7 @@ async fn admin_page(cx: &Cx) -> Result<Response> {
197 // topbar; the address stays a link too.212 // topbar; the address stays a link too.
198 <a class="wordmark-text wordmark-home" href="/">"im"</a>213 <a class="wordmark-text wordmark-home" href="/">"im"</a>
199 <nav class="admin-tabs">(topcoat::view::Unescaped::new_unchecked(nav(&section)))</nav>214 <nav class="admin-tabs">(topcoat::view::Unescaped::new_unchecked(nav(&section)))</nav>
200- <a class="auth-alt" href="/">(escape(&me.email))</a>215+ <a class="auth-alt" href="/">(my_email)</a>
201 </div>216 </div>
202 if let Some(banner) = banner {217 if let Some(banner) = banner {
203 (topcoat::view::Unescaped::new_unchecked(banner))218 (topcoat::view::Unescaped::new_unchecked(banner))
@@ -207,7 +222,9 @@ async fn admin_page(cx: &Cx) -> Result<Response> {
207 </div>222 </div>
208 </main>223 </main>
209 };224 };
210- shell(cx, t(lang, Key::TitleAdmin), Some(&me), stage)225+ shell(cx, t(lang, Key::TitleAdmin), Some(me), Child::new(stage))
226+ .await?
227+ .first()
211 .await?228 .await?
212 .into_response(cx)229 .into_response(cx)
213 }230 }
@@ -330,38 +347,38 @@ async fn users_section(
330 // the button that actually does it. No script required; the live347 // the button that actually does it. No script required; the live
331 // script adds outside-click closing on top.348 // script adds outside-click closing on top.
332 let toggle = if user.disabled {349 let toggle = if user.disabled {
333- confirm_action(350+ confirm_action(ConfirmAction {
334- "user",351+ field: "user",
335- &id,352+ id: &id,
336- "/admin/enable",353+ action: "/admin/enable",
337- t(lang, Key::EnableWord),354+ word: t(lang, Key::EnableWord),
338- "",355+ extra_class: "",
339- &i18n::enable_title(lang, &email),356+ title: &i18n::enable_title(lang, &email),
340- t(lang, Key::EnableCost),357+ cost: t(lang, Key::EnableCost),
341- t(lang, Key::ConfirmEnable),358+ confirm: t(lang, Key::ConfirmEnable),
342- )359+ })
343 } else {360 } else {
344- confirm_action(361+ confirm_action(ConfirmAction {
345- "user",362+ field: "user",
346- &id,363+ id: &id,
347- "/admin/disable",364+ action: "/admin/disable",
348- t(lang, Key::DisableWord),365+ word: t(lang, Key::DisableWord),
349- "",366+ extra_class: "",
350- &i18n::disable_title(lang, &email),367+ title: &i18n::disable_title(lang, &email),
351- t(lang, Key::DisableCost),368+ cost: t(lang, Key::DisableCost),
352- t(lang, Key::ConfirmDisable),369+ confirm: t(lang, Key::ConfirmDisable),
353- )370+ })
354 };371 };
355- let remove = confirm_action(372+ let remove = confirm_action(ConfirmAction {
356- "user",373+ field: "user",
357- &id,374+ id: &id,
358- "/admin/delete",375+ action: "/admin/delete",
359- t(lang, Key::DeleteWord),376+ word: t(lang, Key::DeleteWord),
360- " admin-danger",377+ extra_class: " admin-danger",
361- &i18n::delete_title(lang, &email),378+ title: &i18n::delete_title(lang, &email),
362- t(lang, Key::DeleteCost),379+ cost: t(lang, Key::DeleteCost),
363- t(lang, Key::ConfirmDelete),380+ confirm: t(lang, Key::ConfirmDelete),
364- );381+ });
365 format!(382 format!(
366 r#"{toggle}<form method="post" action="/admin/revoke"><input type="hidden" name="user" value="{id}"><button class="admin-action" type="submit">{sign_out}</button></form>{remove}"#,383 r#"{toggle}<form method="post" action="/admin/revoke"><input type="hidden" name="user" value="{id}"><button class="admin-action" type="submit">{sign_out}</button></form>{remove}"#,
367 sign_out = t(lang, Key::SignOutEverywhere),384 sign_out = t(lang, Key::SignOutEverywhere),
@@ -524,16 +541,16 @@ async fn services_section(
524 kept_word = t(lang, Key::ServiceKept),541 kept_word = t(lang, Key::ServiceKept),
525 )542 )
526 } else {543 } else {
527- confirm_action(544+ confirm_action(ConfirmAction {
528- "key",545+ field: "key",
529- &key,546+ id: &key,
530- "/admin/services_remove",547+ action: "/admin/services_remove",
531- t(lang, Key::Remove),548+ word: t(lang, Key::Remove),
532- " admin-danger",549+ extra_class: " admin-danger",
533- &i18n::remove_service_title(lang, &name),550+ title: &i18n::remove_service_title(lang, &name),
534- t(lang, Key::RemoveCost),551+ cost: t(lang, Key::RemoveCost),
535- t(lang, Key::ConfirmRemove),552+ confirm: t(lang, Key::ConfirmRemove),
536- )553+ })
537 };554 };
538 let (client_cell, uris_cell, registered_cell, client_actions) =555 let (client_cell, uris_cell, registered_cell, client_actions) =
539 match linked(service.client_id.as_ref()) {556 match linked(service.client_id.as_ref()) {
@@ -647,26 +664,26 @@ async fn services_section(
647 /// A client's Rotate/Revoke pair, as the two-step disclosures — the same664 /// A client's Rotate/Revoke pair, as the two-step disclosures — the same
648 /// controls on a linked service row and on a credential-only row.665 /// controls on a linked service row and on a credential-only row.
649 fn client_controls(client_id: &str, name_html: &str, lang: i18n::Lang) -> String {666 fn client_controls(client_id: &str, name_html: &str, lang: i18n::Lang) -> String {
650- let rotate = confirm_action(667+ let rotate = confirm_action(ConfirmAction {
651- "client",668+ field: "client",
652- client_id,669+ id: client_id,
653- "/admin/clients_rotate",670+ action: "/admin/clients_rotate",
654- t(lang, Key::RotateWord),671+ word: t(lang, Key::RotateWord),
655- "",672+ extra_class: "",
656- &i18n::rotate_client_title(lang, name_html),673+ title: &i18n::rotate_client_title(lang, name_html),
657- t(lang, Key::RotateCost),674+ cost: t(lang, Key::RotateCost),
658- t(lang, Key::ConfirmRotate),675+ confirm: t(lang, Key::ConfirmRotate),
659- );676+ });
660- let revoke_action = confirm_action(677+ let revoke_action = confirm_action(ConfirmAction {
661- "client",678+ field: "client",
662- client_id,679+ id: client_id,
663- "/admin/clients_revoke",680+ action: "/admin/clients_revoke",
664- t(lang, Key::RevokeWord),681+ word: t(lang, Key::RevokeWord),
665- " admin-danger",682+ extra_class: " admin-danger",
666- &i18n::revoke_client_title(lang, name_html),683+ title: &i18n::revoke_client_title(lang, name_html),
667- t(lang, Key::RevokeCost),684+ cost: t(lang, Key::RevokeCost),
668- t(lang, Key::ConfirmRevoke),685+ confirm: t(lang, Key::ConfirmRevoke),
669- );686+ });
670 format!("{rotate}{revoke_action}")687 format!("{rotate}{revoke_action}")
671 }688 }
672 689
@@ -749,7 +766,7 @@ struct ServiceForm {
749 async fn services_add(cx: &Cx, Form(input): Form<ServiceForm>) -> Result<Response> {766 async fn services_add(cx: &Cx, Form(input): Form<ServiceForm>) -> Result<Response> {
750 let me = match require_admin(cx).await {767 let me = match require_admin(cx).await {
751 Ok(me) => me,768 Ok(me) => me,
752- Err(redirect) => return Ok(redirect),769+ Err(redirect) => return Ok(*redirect),
753 };770 };
754 let limit = match posted_limit(&input.limit_amount, &input.limit_unit) {771 let limit = match posted_limit(&input.limit_amount, &input.limit_unit) {
755 Ok(limit) => limit,772 Ok(limit) => limit,
@@ -774,7 +791,7 @@ async fn services_add(cx: &Cx, Form(input): Form<ServiceForm>) -> Result<Respons
774 async fn services_edit(cx: &Cx, Form(input): Form<ServiceForm>) -> Result<Response> {791 async fn services_edit(cx: &Cx, Form(input): Form<ServiceForm>) -> Result<Response> {
775 let me = match require_admin(cx).await {792 let me = match require_admin(cx).await {
776 Ok(me) => me,793 Ok(me) => me,
777- Err(redirect) => return Ok(redirect),794+ Err(redirect) => return Ok(*redirect),
778 };795 };
779 let limit = match posted_limit(&input.limit_amount, &input.limit_unit) {796 let limit = match posted_limit(&input.limit_amount, &input.limit_unit) {
780 Ok(limit) => limit,797 Ok(limit) => limit,
@@ -800,7 +817,7 @@ struct ServiceKeyForm {
800 async fn services_remove(cx: &Cx, Form(input): Form<ServiceKeyForm>) -> Result<Response> {817 async fn services_remove(cx: &Cx, Form(input): Form<ServiceKeyForm>) -> Result<Response> {
801 let me = match require_admin(cx).await {818 let me = match require_admin(cx).await {
802 Ok(me) => me,819 Ok(me) => me,
803- Err(redirect) => return Ok(redirect),820+ Err(redirect) => return Ok(*redirect),
804 };821 };
805 let outcome = im_core::services::remove(&app(cx).store, &input.key).await;822 let outcome = im_core::services::remove(&app(cx).store, &input.key).await;
806 service_outcome(cx, &me, outcome).await823 service_outcome(cx, &me, outcome).await
@@ -817,7 +834,7 @@ struct ServiceMoveForm {
817 async fn services_move(cx: &Cx, Form(input): Form<ServiceMoveForm>) -> Result<Response> {834 async fn services_move(cx: &Cx, Form(input): Form<ServiceMoveForm>) -> Result<Response> {
818 let me = match require_admin(cx).await {835 let me = match require_admin(cx).await {
819 Ok(me) => me,836 Ok(me) => me,
820- Err(redirect) => return Ok(redirect),837+ Err(redirect) => return Ok(*redirect),
821 };838 };
822 let up = match input.dir.as_str() {839 let up = match input.dir.as_str() {
823 "up" => true,840 "up" => true,
@@ -862,7 +879,7 @@ struct ClientForm {
862 async fn clients_add(cx: &Cx, Form(input): Form<ClientForm>) -> Result<Response> {879 async fn clients_add(cx: &Cx, Form(input): Form<ClientForm>) -> Result<Response> {
863 let me = match require_admin(cx).await {880 let me = match require_admin(cx).await {
864 Ok(me) => me,881 Ok(me) => me,
865- Err(redirect) => return Ok(redirect),882+ Err(redirect) => return Ok(*redirect),
866 };883 };
867 let name = input.name.trim().to_string();884 let name = input.name.trim().to_string();
868 let uris: Vec<String> = input885 let uris: Vec<String> = input
@@ -890,7 +907,7 @@ struct ClientAction {
890 async fn clients_rotate(cx: &Cx, Form(input): Form<ClientAction>) -> Result<Response> {907 async fn clients_rotate(cx: &Cx, Form(input): Form<ClientAction>) -> Result<Response> {
891 let me = match require_admin(cx).await {908 let me = match require_admin(cx).await {
892 Ok(me) => me,909 Ok(me) => me,
893- Err(redirect) => return Ok(redirect),910+ Err(redirect) => return Ok(*redirect),
894 };911 };
895 // The log line names the client like a person, so the name comes off912 // The log line names the client like a person, so the name comes off
896 // the row before the secret under it moves.913 // the row before the secret under it moves.
@@ -913,7 +930,7 @@ async fn clients_rotate(cx: &Cx, Form(input): Form<ClientAction>) -> Result<Resp
913 async fn clients_revoke(cx: &Cx, Form(input): Form<ClientAction>) -> Result<Response> {930 async fn clients_revoke(cx: &Cx, Form(input): Form<ClientAction>) -> Result<Response> {
914 let me = match require_admin(cx).await {931 let me = match require_admin(cx).await {
915 Ok(me) => me,932 Ok(me) => me,
916- Err(redirect) => return Ok(redirect),933+ Err(redirect) => return Ok(*redirect),
917 };934 };
918 let name = match im_core::oidc::client_by_id(&app(cx).store, &input.client).await? {935 let name = match im_core::oidc::client_by_id(&app(cx).store, &input.client).await? {
919 Some(client) => client.name,936 Some(client) => client.name,
@@ -983,7 +1000,7 @@ struct PolicyForm {
983 async fn settings_save(cx: &Cx, Form(input): Form<PolicyForm>) -> Result<Response> {1000 async fn settings_save(cx: &Cx, Form(input): Form<PolicyForm>) -> Result<Response> {
984 let me = match require_admin(cx).await {1001 let me = match require_admin(cx).await {
985 Ok(me) => me,1002 Ok(me) => me,
986- Err(redirect) => return Ok(redirect),1003+ Err(redirect) => return Ok(*redirect),
987 };1004 };
988 let store = &app(cx).store;1005 let store = &app(cx).store;
989 settings::set_policy(1006 settings::set_policy(
@@ -1361,6 +1378,22 @@ async fn logs_section(cx: &Cx, lang: i18n::Lang) -> Result<String, topcoat::Erro
1361 );1378 );
1362 }1379 }
1363 1380
1381+ let dir_options = format!(
1382+ r#"<option value=""{}>{}</option><option value="oldest"{}>{}</option>"#,
1383+ if dir == events::Dir::Newest {
1384+ " selected"
1385+ } else {
1386+ ""
1387+ },
1388+ t(lang, Key::NewestFirst),
1389+ if dir == events::Dir::Oldest {
1390+ " selected"
1391+ } else {
1392+ ""
1393+ },
1394+ t(lang, Key::OldestFirst),
1395+ );
1396+
1364 Ok(format!(1397 Ok(format!(
1365 r#"<div class="admin-card">1398 r#"<div class="admin-card">
1366 <div class="auth-title">{title}</div>1399 <div class="auth-title">{title}</div>
@@ -1394,21 +1427,7 @@ async fn logs_section(cx: &Cx, lang: i18n::Lang) -> Result<String, topcoat::Erro
1394 q_value = escape(filter.q.as_deref().unwrap_or("")),1427 q_value = escape(filter.q.as_deref().unwrap_or("")),
1395 from_value = escape(&pick("from").unwrap_or_default()),1428 from_value = escape(&pick("from").unwrap_or_default()),
1396 to_value = escape(&pick("to").unwrap_or_default()),1429 to_value = escape(&pick("to").unwrap_or_default()),
1397- dir_options = format!(1430+ dir_options = dir_options,
1398- r#"<option value=""{}>{}</option><option value="oldest"{}>{}</option>"#,
1399- if dir == events::Dir::Newest {
1400- " selected"
1401- } else {
1402- ""
1403- },
1404- t(lang, Key::NewestFirst),
1405- if dir == events::Dir::Oldest {
1406- " selected"
1407- } else {
1408- ""
1409- },
1410- t(lang, Key::OldestFirst),
1411- ),
1412 ))1431 ))
1413 .map(|card| card + LOG_FIT_SCRIPT)1432 .map(|card| card + LOG_FIT_SCRIPT)
1414 }1433 }
@@ -1491,7 +1510,7 @@ struct InviteForm {
1491 async fn invite(cx: &Cx, Form(input): Form<InviteForm>) -> Result<Response> {1510 async fn invite(cx: &Cx, Form(input): Form<InviteForm>) -> Result<Response> {
1492 let me = match require_admin(cx).await {1511 let me = match require_admin(cx).await {
1493 Ok(me) => me,1512 Ok(me) => me,
1494- Err(redirect) => return Ok(redirect),1513+ Err(redirect) => return Ok(*redirect),
1495 };1514 };
1496 let store = &app(cx).store;1515 let store = &app(cx).store;
1497 let email = input.email.trim().to_string();1516 let email = input.email.trim().to_string();
@@ -1543,7 +1562,7 @@ struct UserEmailForm {
1543 async fn user_email(cx: &Cx, Form(input): Form<UserEmailForm>) -> Result<Response> {1562 async fn user_email(cx: &Cx, Form(input): Form<UserEmailForm>) -> Result<Response> {
1544 let me = match require_admin(cx).await {1563 let me = match require_admin(cx).await {
1545 Ok(me) => me,1564 Ok(me) => me,
1546- Err(redirect) => return Ok(redirect),1565+ Err(redirect) => return Ok(*redirect),
1547 };1566 };
1548 let store = &app(cx).store;1567 let store = &app(cx).store;
1549 let user_id = UserId::from(input.user);1568 let user_id = UserId::from(input.user);
@@ -1568,7 +1587,7 @@ struct InviteAction {
1568 async fn uninvite(cx: &Cx, Form(input): Form<InviteAction>) -> Result<Response> {1587 async fn uninvite(cx: &Cx, Form(input): Form<InviteAction>) -> Result<Response> {
1569 let me = match require_admin(cx).await {1588 let me = match require_admin(cx).await {
1570 Ok(me) => me,1589 Ok(me) => me,
1571- Err(redirect) => return Ok(redirect),1590+ Err(redirect) => return Ok(*redirect),
1572 };1591 };
1573 let store = &app(cx).store;1592 let store = &app(cx).store;
1574 let email = accounts::revoke_invite(store, &input.invite).await?;1593 let email = accounts::revoke_invite(store, &input.invite).await?;
@@ -1583,7 +1602,7 @@ async fn uninvite(cx: &Cx, Form(input): Form<InviteAction>) -> Result<Response>
1583 async fn delete(cx: &Cx, Form(input): Form<UserAction>) -> Result<Response> {1602 async fn delete(cx: &Cx, Form(input): Form<UserAction>) -> Result<Response> {
1584 let me = match require_admin(cx).await {1603 let me = match require_admin(cx).await {
1585 Ok(me) => me,1604 Ok(me) => me,
1586- Err(redirect) => return Ok(redirect),1605+ Err(redirect) => return Ok(*redirect),
1587 };1606 };
1588 let store = &app(cx).store;1607 let store = &app(cx).store;
1589 let user_id = UserId::from(input.user);1608 let user_id = UserId::from(input.user);
@@ -1603,7 +1622,7 @@ struct UserAction {
1603 async fn revoke(cx: &Cx, Form(input): Form<UserAction>) -> Result<Response> {1622 async fn revoke(cx: &Cx, Form(input): Form<UserAction>) -> Result<Response> {
1604 let me = match require_admin(cx).await {1623 let me = match require_admin(cx).await {
1605 Ok(me) => me,1624 Ok(me) => me,
1606- Err(redirect) => return Ok(redirect),1625+ Err(redirect) => return Ok(*redirect),
1607 };1626 };
1608 let store = &app(cx).store;1627 let store = &app(cx).store;
1609 let user_id = UserId::from(input.user);1628 let user_id = UserId::from(input.user);
@@ -1636,7 +1655,7 @@ struct SessionRevokeForm {
1636 async fn session_revoke(cx: &Cx, Form(input): Form<SessionRevokeForm>) -> Result<Response> {1655 async fn session_revoke(cx: &Cx, Form(input): Form<SessionRevokeForm>) -> Result<Response> {
1637 let me = match require_admin(cx).await {1656 let me = match require_admin(cx).await {
1638 Ok(me) => me,1657 Ok(me) => me,
1639- Err(redirect) => return Ok(redirect),1658+ Err(redirect) => return Ok(*redirect),
1640 };1659 };
1641 let user_id = UserId::from(input.user.clone());1660 let user_id = UserId::from(input.user.clone());
1642 if !im_core::sessions::revoke_owned_session(&app(cx).store, &user_id, &input.session).await? {1661 if !im_core::sessions::revoke_owned_session(&app(cx).store, &user_id, &input.session).await? {
@@ -1659,7 +1678,7 @@ async fn enable(cx: &Cx, Form(input): Form<UserAction>) -> Result<Response> {
1659 async fn set_disabled(cx: &Cx, input: UserAction, disabled: bool) -> Result<Response> {1678 async fn set_disabled(cx: &Cx, input: UserAction, disabled: bool) -> Result<Response> {
1660 let me = match require_admin(cx).await {1679 let me = match require_admin(cx).await {
1661 Ok(me) => me,1680 Ok(me) => me,
1662- Err(redirect) => return Ok(redirect),1681+ Err(redirect) => return Ok(*redirect),
1663 };1682 };
1664 let store = &app(cx).store;1683 let store = &app(cx).store;
1665 let user_id = UserId::from(input.user);1684 let user_id = UserId::from(input.user);
@@ -1710,7 +1729,7 @@ struct SmtpForm {
1710 async fn smtp_save(cx: &Cx, Form(input): Form<SmtpForm>) -> Result<Response> {1729 async fn smtp_save(cx: &Cx, Form(input): Form<SmtpForm>) -> Result<Response> {
1711 let me = match require_admin(cx).await {1730 let me = match require_admin(cx).await {
1712 Ok(me) => me,1731 Ok(me) => me,
1713- Err(redirect) => return Ok(redirect),1732+ Err(redirect) => return Ok(*redirect),
1714 };1733 };
1715 let store = &app(cx).store;1734 let store = &app(cx).store;
1716 let value = Smtp {1735 let value = Smtp {
@@ -1733,7 +1752,7 @@ async fn smtp_save(cx: &Cx, Form(input): Form<SmtpForm>) -> Result<Response> {
1733 async fn smtp_test(cx: &Cx) -> Result<Response> {1752 async fn smtp_test(cx: &Cx) -> Result<Response> {
1734 let me = match require_admin(cx).await {1753 let me = match require_admin(cx).await {
1735 Ok(me) => me,1754 Ok(me) => me,
1736- Err(redirect) => return Ok(redirect),1755+ Err(redirect) => return Ok(*redirect),
1737 };1756 };
1738 if !settings::smtp(&app(cx).store).await?.configured() {1757 if !settings::smtp(&app(cx).store).await?.configured() {
1739 return back(cx, "mail", "&error=sender_unset");1758 return back(cx, "mail", "&error=sender_unset");
@@ -1778,7 +1797,7 @@ struct MessageForm {
1778 async fn message(cx: &Cx, Form(input): Form<MessageForm>) -> Result<Response> {1797 async fn message(cx: &Cx, Form(input): Form<MessageForm>) -> Result<Response> {
1779 let me = match require_admin(cx).await {1798 let me = match require_admin(cx).await {
1780 Ok(me) => me,1799 Ok(me) => me,
1781- Err(redirect) => return Ok(redirect),1800+ Err(redirect) => return Ok(*redirect),
1782 };1801 };
1783 let store = &app(cx).store;1802 let store = &app(cx).store;
1784 if !settings::smtp(store).await?.configured() {1803 if !settings::smtp(store).await?.configured() {
@@ -1834,7 +1853,7 @@ async fn message(cx: &Cx, Form(input): Form<MessageForm>) -> Result<Response> {
1834 async fn smtp_check(cx: &Cx) -> Result<Response> {1853 async fn smtp_check(cx: &Cx) -> Result<Response> {
1835 let me = match require_admin(cx).await {1854 let me = match require_admin(cx).await {
1836 Ok(me) => me,1855 Ok(me) => me,
1837- Err(redirect) => return Ok(redirect),1856+ Err(redirect) => return Ok(*redirect),
1838 };1857 };
1839 if !settings::smtp(&app(cx).store).await?.configured() {1858 if !settings::smtp(&app(cx).store).await?.configured() {
1840 return back(cx, "mail", "&error=sender_unset");1859 return back(cx, "mail", "&error=sender_unset");
crates/im-web/src/auth.rsmodified+10 -11
@@ -55,13 +55,12 @@ fn logout_target(raw: Option<&str>, services: &[im_core::services::Service]) ->
55 if raw.starts_with('/') && !raw.starts_with("//") {55 if raw.starts_with('/') && !raw.starts_with("//") {
56 return raw.to_string();56 return raw.to_string();
57 }57 }
58- if let Some(origin) = url_origin(raw) {58+ if let Some(origin) = url_origin(raw)
59- if services59+ && services
60 .iter()60 .iter()
61 .any(|s| url_origin(&s.url).is_some_and(|known| known == origin))61 .any(|s| url_origin(&s.url).is_some_and(|known| known == origin))
62- {62+ {
63- return raw.to_string();63+ return raw.to_string();
64- }
65 }64 }
66 "/".to_string()65 "/".to_string()
67 }66 }
@@ -519,12 +518,12 @@ async fn revoke_session(cx: &Cx, Form(input): Form<SessionRevokeForm>) -> Redire
519 return see("/".to_string());518 return see("/".to_string());
520 };519 };
521 let store = &server::app(cx).store;520 let store = &server::app(cx).store;
522- if let Some(presented) = server::presented_session(cx) {521+ if let Some(presented) = server::presented_session(cx)
523- if im_core::accounts::hash_token(&presented) == input.session {522+ && im_core::accounts::hash_token(&presented) == input.session
524- im_core::sessions::revoke_session(store, &presented).await?;523+ {
525- server::clear_session_cookie(cx);524+ im_core::sessions::revoke_session(store, &presented).await?;
526- return see("/".to_string());525+ server::clear_session_cookie(cx);
527- }526+ return see("/".to_string());
528 }527 }
529 // The row's address, when it is still there, is the useful half of the528 // The row's address, when it is still there, is the useful half of the
530 // log line — which of their devices they just killed.529 // log line — which of their devices they just killed.
crates/im-web/src/dropdown.rsmodified+3 -3
@@ -15,9 +15,9 @@
15 15
16 use topcoat::Result;16 use topcoat::Result;
17 use topcoat::context::Cx;17 use topcoat::context::Cx;
18-use topcoat::view::{Unescaped, view};18+use topcoat::view::{Unescaped, View, view};
19 19
20-pub async fn dropdown_script(cx: &Cx) -> Result {20+pub async fn dropdown_script(cx: &Cx) -> Result<impl View + '_> {
21 const JS: &str = "\21 const JS: &str = "\
22 (function () {\22 (function () {\
23 function enhanceAll() { document.querySelectorAll('select.auth-input').forEach(enhance); }\23 function enhanceAll() { document.querySelectorAll('select.auth-input').forEach(enhance); }\
@@ -242,5 +242,5 @@ pub async fn dropdown_script(cx: &Cx) -> Result {
242 }, true);\242 }, true);\
243 enhanceAll();\243 enhanceAll();\
244 })();";244 })();";
245- view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }245+ Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> })
246 }246 }
crates/im-web/src/layout.rsmodified+40 -27
@@ -5,7 +5,7 @@ use im_core::model::User;
5 use topcoat::Result;5 use topcoat::Result;
6 use topcoat::asset::{Asset, asset};6 use topcoat::asset::{Asset, asset};
7 use topcoat::context::Cx;7 use topcoat::context::Cx;
8-use topcoat::view::view;8+use topcoat::view::{BoxView, Child, View, ViewExt, view};
9 9
10 use crate::i18n::{Key, Lang, lang_of, t};10 use crate::i18n::{Key, Lang, lang_of, t};
11 use crate::server;11 use crate::server;
@@ -15,13 +15,13 @@ pub(crate) const STYLE: Asset = asset!("assets/main.css");
15 15
16 /// The mark, in the word as it is in the name: lower case, the Turkish16 /// The mark, in the word as it is in the name: lower case, the Turkish
17 /// tittle. Text-only here — the auth card is the whole chrome.17 /// tittle. Text-only here — the auth card is the whole chrome.
18-pub async fn wordmark(cx: &Cx) -> Result {18+pub async fn wordmark(cx: &Cx) -> Result<impl View + '_> {
19- view! {19+ Ok(view! {
20 cx =>20 cx =>
21 <span class="wordmark">21 <span class="wordmark">
22 <span class="wordmark-text">"im"</span>22 <span class="wordmark-text">"im"</span>
23 </span>23 </span>
24- }24+ })
25 }25 }
26 26
27 /// The signed-in chrome's wordmark with the family behind it: the `im`27 /// The signed-in chrome's wordmark with the family behind it: the `im`
@@ -31,7 +31,7 @@ pub async fn wordmark(cx: &Cx) -> Result {
31 /// is CSS on `:hover` / `:focus-within`. A family with no siblings renders31 /// is CSS on `:hover` / `:focus-within`. A family with no siblings renders
32 /// the bare mark — nothing to reveal. The list is the stored one, the same32 /// the bare mark — nothing to reveal. The list is the stored one, the same
33 /// rows `/family` serves, minus im's own row.33 /// rows `/family` serves, minus im's own row.
34-pub async fn family_wordmark(cx: &Cx) -> Result {34+pub async fn family_wordmark(cx: &Cx) -> Result<BoxView<'_>> {
35 let services = im_core::services::list(&server::app(cx).store).await?;35 let services = im_core::services::list(&server::app(cx).store).await?;
36 let siblings = services36 let siblings = services
37 .iter()37 .iter()
@@ -43,10 +43,10 @@ pub async fn family_wordmark(cx: &Cx) -> Result {
43 })43 })
44 .collect::<Vec<_>>();44 .collect::<Vec<_>>();
45 if siblings.is_empty() {45 if siblings.is_empty() {
46- return wordmark(cx).await;46+ return wordmark(cx).await.map(ViewExt::boxed);
47 }47 }
48 let marks = siblings.join(r#"<span class="trio-sep">·</span>"#);48 let marks = siblings.join(r#"<span class="trio-sep">·</span>"#);
49- view! {49+ Ok(view! {
50 cx =>50 cx =>
51 <div class="wordmark-family">51 <div class="wordmark-family">
52 <span class="wordmark" tabindex="0">52 <span class="wordmark" tabindex="0">
@@ -55,19 +55,21 @@ pub async fn family_wordmark(cx: &Cx) -> Result {
55 <nav class="service-trio">(topcoat::view::Unescaped::new_unchecked(marks))</nav>55 <nav class="service-trio">(topcoat::view::Unescaped::new_unchecked(marks))</nav>
56 </div>56 </div>
57 }57 }
58+ .boxed())
58 }59 }
59 60
60 /// The profile card's face: the photo when the account has one, the name's61 /// The profile card's face: the photo when the account has one, the name's
61 /// first letter on a quiet tile when it does not. The URL's `?v=` is the62 /// first letter on a quiet tile when it does not. The URL's `?v=` is the
62 /// row's `photo_version` — the same number `/directory` answers with — so63 /// row's `photo_version` — the same number `/directory` answers with — so
63 /// a changed photo is a changed URL, in this process and in every sibling.64 /// a changed photo is a changed URL, in this process and in every sibling.
64-pub async fn avatar(cx: &Cx, user: &im_core::model::User) -> Result {65+pub async fn avatar<'a>(cx: &'a Cx, user: &'a im_core::model::User) -> Result<BoxView<'a>> {
65 if user.has_photo {66 if user.has_photo {
66 let src = format!("/photo/{}?v={}", user.id, user.photo_version);67 let src = format!("/photo/{}?v={}", user.id, user.photo_version);
67- view! {68+ Ok(view! {
68 cx =>69 cx =>
69 <img class="profile-avatar" src=(src) alt=(user.name.clone())>70 <img class="profile-avatar" src=(src) alt=(user.name.clone())>
70 }71 }
72+ .boxed())
71 } else {73 } else {
72 let initial = user74 let initial = user
73 .name75 .name
@@ -76,11 +78,13 @@ pub async fn avatar(cx: &Cx, user: &im_core::model::User) -> Result {
76 .unwrap_or('?')78 .unwrap_or('?')
77 .to_uppercase()79 .to_uppercase()
78 .to_string();80 .to_string();
79- view! {81+ Ok(view! {
80 cx =>82 cx =>
81 <span class="profile-avatar profile-avatar-initial">(initial)</span>83 <span class="profile-avatar profile-avatar-initial">(initial)</span>
82 }84 }
85+ .boxed())
83 }86 }
87+
84 }88 }
85 89
86 /// The one script im serves, and the only behavior it carries: the avatar90 /// The one script im serves, and the only behavior it carries: the avatar
@@ -94,7 +98,7 @@ pub async fn avatar(cx: &Cx, user: &im_core::model::User) -> Result {
94 /// document listeners, so the hard-post re-render never needs rewiring.98 /// document listeners, so the hard-post re-render never needs rewiring.
95 /// Emitted by the landing and the person page — every surface that draws a99 /// Emitted by the landing and the person page — every surface that draws a
96 /// clickable face.100 /// clickable face.
97-pub async fn avatar_script(cx: &Cx, lang: Lang) -> Result {101+pub async fn avatar_script(cx: &Cx, lang: Lang) -> Result<impl View + '_> {
98 use topcoat::view::Unescaped;102 use topcoat::view::Unescaped;
99 /// Single-quoted into the script below; the staged strings carry no103 /// Single-quoted into the script below; the staged strings carry no
100 /// quoting of their own, and this keeps it true if one ever does.104 /// quoting of their own, and this keeps it true if one ever does.
@@ -212,7 +216,7 @@ pub async fn avatar_script(cx: &Cx, lang: Lang) -> Result {
212 "__IM_CANCEL_UPLOAD__",216 "__IM_CANCEL_UPLOAD__",
213 &js_escape(t(lang, Key::CancelUploadLabel)),217 &js_escape(t(lang, Key::CancelUploadLabel)),
214 );218 );
215- view! { cx => <script>(Unescaped::new_unchecked(js))</script> }219+ Ok(view! { cx => <script>(Unescaped::new_unchecked(js))</script> })
216 }220 }
217 221
218 /// Soft navigation, iz's model cut to im's shape: same-app links and form222 /// Soft navigation, iz's model cut to im's shape: same-app links and form
@@ -222,7 +226,7 @@ pub async fn avatar_script(cx: &Cx, lang: Lang) -> Result {
222 /// belong to the avatar script above and are left to it. Global listeners226 /// belong to the avatar script above and are left to it. Global listeners
223 /// live on document/window and survive every swap; the guard makes the227 /// live on document/window and survive every swap; the guard makes the
224 /// re-created script a no-op.228 /// re-created script a no-op.
225-pub async fn soft_nav_script(cx: &Cx) -> Result {229+pub async fn soft_nav_script(cx: &Cx) -> Result<impl View + '_> {
226 use topcoat::view::Unescaped;230 use topcoat::view::Unescaped;
227 const JS: &str = r#"(function () {231 const JS: &str = r#"(function () {
228 if (window.__imSoft) { return; }232 if (window.__imSoft) { return; }
@@ -410,7 +414,7 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
410 .catch(function () {});414 .catch(function () {});
411 };415 };
412 })();"#;416 })();"#;
413- view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }417+ Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> })
414 }418 }
415 419
416 /// The live channel's client, iz's shape: a bare tick says *something*420 /// The live channel's client, iz's shape: a bare tick says *something*
@@ -418,7 +422,7 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
418 /// ordinary gate answers — and morphs with fields and scroll intact. A422 /// ordinary gate answers — and morphs with fields and scroll intact. A
419 /// focused field freezes the refresh mid-typing. Mounted only for a signed-in423 /// focused field freezes the refresh mid-typing. Mounted only for a signed-in
420 /// viewer, so auth screens never reconnect against a 401.424 /// viewer, so auth screens never reconnect against a 401.
421-pub async fn live_script(cx: &Cx) -> Result {425+pub async fn live_script(cx: &Cx) -> Result<impl View + '_> {
422 use topcoat::view::Unescaped;426 use topcoat::view::Unescaped;
423 const JS: &str = r#"(function () {427 const JS: &str = r#"(function () {
424 if (window.__imLive) { return; }428 if (window.__imLive) { return; }
@@ -433,19 +437,28 @@ pub async fn live_script(cx: &Cx) -> Result {
433 src.onmessage = function () { schedule(); };437 src.onmessage = function () { schedule(); };
434 } catch (err) {}438 } catch (err) {}
435 })();"#;439 })();"#;
436- view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }440+ Ok(view! { cx => <script>(Unescaped::new_unchecked(JS))</script> })
437 }441 }
438 442
439 /// A full document around an already-rendered stage — the same way443 /// A full document around an already-rendered stage — the same way
440 /// izlek-web's `#[layout]` receives its slot. The viewer stamps the chrome:444 /// izlek-web's `#[layout]` receives its slot. The viewer stamps the chrome:
441 /// their theme/language/ui when signed in, English/light/instrument when445 /// their theme/language/ui when signed in, English/light/instrument when
442 /// not — mirroring iz's root_layout, minus its build stamp.446 /// not — mirroring iz's root_layout, minus its build stamp.
443-pub async fn shell(cx: &Cx, title: &str, viewer: Option<&User>, stage: Result) -> Result {447+pub async fn shell<'a>(
444- let stage = stage?;448+ cx: &'a Cx,
445- let lang = lang_of(viewer);449+ title: impl Into<String>,
446- let dark = viewer.is_some_and(|user| user.theme == "dark");450+ viewer: Option<User>,
447- let ui = viewer.map_or("instrument", |user| user.ui.as_str());451+ stage: Child<'a>,
448- view! {452+) -> Result<impl View + 'a> {
453+ let title = title.into();
454+ let lang = lang_of(viewer.as_ref());
455+ let dark = viewer.as_ref().is_some_and(|user| user.theme == "dark");
456+ let ui = viewer
457+ .as_ref()
458+ .map_or("instrument", |user| user.ui.as_str())
459+ .to_string();
460+ let live = viewer.is_some();
461+ Ok(view! {
449 cx =>462 cx =>
450 <!DOCTYPE html>463 <!DOCTYPE html>
451 <html lang=(lang.code()) data-theme=(dark.then_some("dark")) data-ui=(ui)>464 <html lang=(lang.code()) data-theme=(dark.then_some("dark")) data-ui=(ui)>
@@ -463,12 +476,12 @@ pub async fn shell(cx: &Cx, title: &str, viewer: Option<&User>, stage: Result) -
463 </head>476 </head>
464 <body>477 <body>
465 (stage)478 (stage)
466- (soft_nav_script(cx).await?)479+ (soft_nav_script(cx).await?.first().await?)
467- if viewer.is_some() {480+ if live {
468- (live_script(cx).await?)481+ (live_script(cx).await?.first().await?)
469- (crate::dropdown::dropdown_script(cx).await?)482+ (crate::dropdown::dropdown_script(cx).await?.first().await?)
470 }483 }
471 </body>484 </body>
472 </html>485 </html>
473- }486+ })
474 }487 }
crates/im-web/src/live.rsmodified+50 -52
@@ -49,61 +49,59 @@ async fn live(cx: &Cx) -> topcoat::Result<Response> {
49 let events = futures_util::stream::unfold(49 let events = futures_util::stream::unfold(
50 (rx, deadline, stopping),50 (rx, deadline, stopping),
51 |(mut rx, deadline, mut stopping)| async move {51 |(mut rx, deadline, mut stopping)| async move {
52- loop {52+ // Already going down: end, so this connection is not one the
53- // Already going down: end, so this connection is not one the53+ // shutdown has to sit and wait out.
54- // shutdown has to sit and wait out.54+ if stopping.as_ref().is_some_and(|watch| *watch.borrow()) {
55- if stopping.as_ref().is_some_and(|watch| *watch.borrow()) {55+ return None;
56- return None;56+ }
57- }57+ let left = deadline.saturating_duration_since(Instant::now());
58- let left = deadline.saturating_duration_since(Instant::now());58+ if left.is_zero() {
59- if left.is_zero() {59+ return None;
60- return None;60+ }
61+ // Three things end the wait: an announcement, the window
62+ // running out, and the server being told to stop. The third
63+ // is watched rather than polled, so SIGTERM is felt at once.
64+ let heard = tokio::time::timeout(left, async {
65+ match stopping.as_mut() {
66+ Some(watch) => tokio::select! {
67+ _ = watch.changed() => None,
68+ got = rx.recv() => Some(got),
69+ },
70+ None => Some(rx.recv().await),
61 }71 }
62- // Three things end the wait: an announcement, the window72+ })
63- // running out, and the server being told to stop. The third73+ .await;
64- // is watched rather than polled, so SIGTERM is felt at once.74+ match heard {
65- let heard = tokio::time::timeout(left, async {75+ // The window closed, or the server is stopping. Ending
66- match stopping.as_mut() {76+ // the stream is the point: the browser reconnects by
67- Some(watch) => tokio::select! {77+ // itself and authenticates again.
68- _ = watch.changed() => None,78+ Err(_) | Ok(None) => return None,
69- got = rx.recv() => Some(got),79+ // The broadcaster is gone, which means the process is
70- },80+ // going with it.
71- None => Some(rx.recv().await),81+ Ok(Some(Err(RecvError::Closed))) => return None,
72- }82+ // This reader fell behind and announcements were dropped.
73- })83+ // Which ones is unknowable, so the tick says "re-read
74- .await;84+ // everything" — the client refetches the whole page, so
75- match heard {85+ // a lagged tick and a plain tick are the same frame.
76- // The window closed, or the server is stopping. Ending86+ Ok(Some(Err(RecvError::Lagged(_)))) | Ok(Some(Ok(server::LiveEvent::Tick))) => {}
77- // the stream is the point: the browser reconnects by87+ // One member's row changed. The frame names which one —
78- // itself and authenticates again.88+ // im's own client still just re-fetches the page it is
79- Err(_) | Ok(None) => return None,89+ // on, so the payload is forward-compatibility for a
80- // The broadcaster is gone, which means the process is90+ // future page that can react to its own subject alone.
81- // going with it.91+ Ok(Some(Ok(server::LiveEvent::Profile(member)))) => {
82- Ok(Some(Err(RecvError::Closed))) => return None,92+ return Some((
83- // This reader fell behind and announcements were dropped.93+ Ok::<_, std::convert::Infallible>(Event::new().data(
84- // Which ones is unknowable, so the tick says "re-read94+ serde_json::json!({ "kind": "profile", "sub": member.sub })
85- // everything" — the client refetches the whole page, so95+ .to_string(),
86- // a lagged tick and a plain tick are the same frame.96+ )),
87- Ok(Some(Err(RecvError::Lagged(_)))) | Ok(Some(Ok(server::LiveEvent::Tick))) => {}97+ (rx, deadline, stopping),
88- // One member's row changed. The frame names which one —98+ ));
89- // im's own client still just re-fetches the page it is
90- // on, so the payload is forward-compatibility for a
91- // future page that can react to its own subject alone.
92- Ok(Some(Ok(server::LiveEvent::Profile(member)))) => {
93- return Some((
94- Ok::<_, std::convert::Infallible>(Event::new().data(
95- serde_json::json!({ "kind": "profile", "sub": member.sub })
96- .to_string(),
97- )),
98- (rx, deadline, stopping),
99- ));
100- }
101 }99 }
102- return Some((
103- Ok::<_, std::convert::Infallible>(Event::new().data("{}")),
104- (rx, deadline, stopping),
105- ));
106 }100 }
101+ Some((
102+ Ok::<_, std::convert::Infallible>(Event::new().data("{}")),
103+ (rx, deadline, stopping),
104+ ))
107 },105 },
108 );106 );
109 107
crates/im-web/src/pages.rsmodified+83 -56
@@ -9,7 +9,7 @@ use topcoat::context::Cx;
9 use topcoat::router::error::see_other;9 use topcoat::router::error::see_other;
10 use topcoat::router::response::{IntoResponse, Response};10 use topcoat::router::response::{IntoResponse, Response};
11 use topcoat::router::{page, path_param, route};11 use topcoat::router::{page, path_param, route};
12-use topcoat::view::view;12+use topcoat::view::{BoxView, Child, View, ViewExt, view};
13 13
14 use crate::i18n::{Key, Lang, lang_of, t};14 use crate::i18n::{Key, Lang, lang_of, t};
15 use crate::layout::{avatar, family_wordmark, shell, wordmark};15 use crate::layout::{avatar, family_wordmark, shell, wordmark};
@@ -161,21 +161,21 @@ fn current_query(cx: &Cx) -> String {
161 /// The front door: the sign-in card, or the signed-in landing when the161 /// The front door: the sign-in card, or the signed-in landing when the
162 /// browser already holds a session.162 /// browser already holds a session.
163 #[page("/")]163 #[page("/")]
164-async fn landing(cx: &Cx) -> Result {164+async fn landing(cx: &Cx) -> Result<BoxView<'_>> {
165 match server::current_user(cx).await {165 match server::current_user(cx).await {
166- Some(user) => signed_in(cx, &user).await,166+ Some(user) => signed_in(cx, user).await.map(ViewExt::boxed),
167- None => login_card(cx).await,167+ None => login_card(cx).await.map(ViewExt::boxed),
168 }168 }
169 }169 }
170 170
171 /// `/login` is the same card with a `back` it must keep: the `/authorize`171 /// `/login` is the same card with a `back` it must keep: the `/authorize`
172 /// call the browser was in the middle of.172 /// call the browser was in the middle of.
173 #[page("/login")]173 #[page("/login")]
174-async fn login(cx: &Cx) -> Result {174+async fn login(cx: &Cx) -> Result<BoxView<'_>> {
175 login_card(cx).await175 login_card(cx).await
176 }176 }
177 177
178-async fn login_card(cx: &Cx) -> Result {178+async fn login_card(cx: &Cx) -> Result<BoxView<'_>> {
179 // No session to read a preference from — mirroring iz's auth pages.179 // No session to read a preference from — mirroring iz's auth pages.
180 let lang = Lang::En;180 let lang = Lang::En;
181 let query = current_query(cx);181 let query = current_query(cx);
@@ -186,7 +186,7 @@ async fn login_card(cx: &Cx) -> Result {
186 cx =>186 cx =>
187 <main class="auth-stage">187 <main class="auth-stage">
188 <div class="auth-column">188 <div class="auth-column">
189- (wordmark(cx).await?)189+ (wordmark(cx).await?.first().await?)
190 <div class="auth-card">190 <div class="auth-card">
191 <div class="auth-head">191 <div class="auth-head">
192 <div class="auth-title">(t(lang, Key::SignInTitle))</div>192 <div class="auth-title">(t(lang, Key::SignInTitle))</div>
@@ -230,7 +230,7 @@ async fn login_card(cx: &Cx) -> Result {
230 </div>230 </div>
231 </main>231 </main>
232 };232 };
233- shell(cx, t(lang, Key::TitleSignIn), None, stage).await233+ shell(cx, t(lang, Key::TitleSignIn), None, Child::new(stage)).await.map(ViewExt::boxed)
234 }234 }
235 235
236 /// The second factor. Reached only with a pending-login cookie; without one236 /// The second factor. Reached only with a pending-login cookie; without one
@@ -246,7 +246,7 @@ async fn totp(cx: &Cx) -> Result<Response> {
246 cx =>246 cx =>
247 <main class="auth-stage">247 <main class="auth-stage">
248 <div class="auth-column">248 <div class="auth-column">
249- (wordmark(cx).await?)249+ (wordmark(cx).await?.first().await?)
250 <div class="auth-card">250 <div class="auth-card">
251 <div class="auth-head">251 <div class="auth-head">
252 <div class="auth-title">(t(lang, Key::TotpTitle))</div>252 <div class="auth-title">(t(lang, Key::TotpTitle))</div>
@@ -277,9 +277,11 @@ async fn totp(cx: &Cx) -> Result<Response> {
277 </div>277 </div>
278 </main>278 </main>
279 };279 };
280- shell(cx, t(lang, Key::TitleTotp), None, stage)280+ shell(cx, t(lang, Key::TitleTotp), None, Child::new(stage))
281- .await?281+ .await?
282- .into_response(cx)282+ .first()
283+ .await?
284+ .into_response(cx)
283 }285 }
284 _ => see_other("/login").into_response(cx),286 _ => see_other("/login").into_response(cx),
285 }287 }
@@ -305,7 +307,7 @@ async fn invite(cx: &Cx) -> Result<Response> {
305 cx =>307 cx =>
306 <main class="auth-stage">308 <main class="auth-stage">
307 <div class="auth-column">309 <div class="auth-column">
308- (wordmark(cx).await?)310+ (wordmark(cx).await?.first().await?)
309 <div class="auth-card">311 <div class="auth-card">
310 <div class="auth-head">312 <div class="auth-head">
311 <div class="auth-title">(t(lang, Key::InviteTitle))</div>313 <div class="auth-title">(t(lang, Key::InviteTitle))</div>
@@ -363,6 +365,7 @@ async fn invite(cx: &Cx) -> Result<Response> {
363 </div>365 </div>
364 </main>366 </main>
365 }367 }
368+ .boxed()
366 } else {369 } else {
367 let code = match &invite {370 let code = match &invite {
368 None => "invite_invalid",371 None => "invite_invalid",
@@ -373,7 +376,7 @@ async fn invite(cx: &Cx) -> Result<Response> {
373 cx =>376 cx =>
374 <main class="auth-stage">377 <main class="auth-stage">
375 <div class="auth-column">378 <div class="auth-column">
376- (wordmark(cx).await?)379+ (wordmark(cx).await?.first().await?)
377 <div class="auth-card">380 <div class="auth-card">
378 <div class="auth-head">381 <div class="auth-head">
379 <div class="auth-title">(t(lang, Key::InviteDeadTitle))</div>382 <div class="auth-title">(t(lang, Key::InviteDeadTitle))</div>
@@ -384,8 +387,11 @@ async fn invite(cx: &Cx) -> Result<Response> {
384 </div>387 </div>
385 </main>388 </main>
386 }389 }
390+ .boxed()
387 };391 };
388- shell(cx, t(lang, Key::TitleInvited), None, stage)392+ shell(cx, t(lang, Key::TitleInvited), None, Child::new(stage))
393+ .await?
394+ .first()
389 .await?395 .await?
390 .into_response(cx)396 .into_response(cx)
391 }397 }
@@ -414,12 +420,10 @@ async fn enroll(cx: &Cx) -> Result<Response> {
414 let issuer = &server::app(cx).config.issuer;420 let issuer = &server::app(cx).config.issuer;
415 let uri = im_core::totp::totp_uri("im", &user.email, &secret);421 let uri = im_core::totp::totp_uri("im", &user.email, &secret);
416 let qr = qrcode::QrCode::new(uri.as_bytes())422 let qr = qrcode::QrCode::new(uri.as_bytes())
417- .and_then(|code| {423+ .map(|code| {
418- Ok::<_, qrcode::types::QrError>(424+ code.render::<qrcode::render::svg::Color>()
419- code.render::<qrcode::render::svg::Color>()425+ .min_dimensions(200, 200)
420- .min_dimensions(200, 200)426+ .build()
421- .build(),
422- )
423 })427 })
424 .map_err(|e| topcoat::Error::from(std::io::Error::other(format!("qr: {e}"))))?;428 .map_err(|e| topcoat::Error::from(std::io::Error::other(format!("qr: {e}"))))?;
425 let manual = im_core::totp::display_secret(&secret);429 let manual = im_core::totp::display_secret(&secret);
@@ -432,7 +436,7 @@ async fn enroll(cx: &Cx) -> Result<Response> {
432 cx =>436 cx =>
433 <main class="auth-stage">437 <main class="auth-stage">
434 <div class="auth-column">438 <div class="auth-column">
435- (wordmark(cx).await?)439+ (wordmark(cx).await?.first().await?)
436 <div class="auth-card">440 <div class="auth-card">
437 <div class="auth-head">441 <div class="auth-head">
438 <div class="auth-title">(t(lang, Key::EnrollTitle))</div>442 <div class="auth-title">(t(lang, Key::EnrollTitle))</div>
@@ -465,7 +469,9 @@ async fn enroll(cx: &Cx) -> Result<Response> {
465 </div>469 </div>
466 </main>470 </main>
467 };471 };
468- shell(cx, t(lang, Key::TitleEnroll), Some(&user), stage)472+ shell(cx, t(lang, Key::TitleEnroll), Some(user), Child::new(stage))
473+ .await?
474+ .first()
469 .await?475 .await?
470 .into_response(cx)476 .into_response(cx)
471 }477 }
@@ -648,16 +654,14 @@ fn apps_html(apps: &[im_core::oidc::ConnectedApp], lang: Lang) -> String {
648 }654 }
649 rows655 rows
650 }656 }
651-
652-/// The signed-in landing. im is an auth service, not an app: this page is
653 /// the proof of session, the person's profile — photo and the counts their657 /// the proof of session, the person's profile — photo and the counts their
654 /// identity has earned — and the way out. izlek gives a profile its own658 /// identity has earned — and the way out. izlek gives a profile its own
655 /// page under `/people`; im has exactly one signed-in screen, so the659 /// page under `/people`; im has exactly one signed-in screen, so the
656 /// profile is a section of it. Six cards in one column ran twice the height660 /// profile is a section of it. Six cards in one column ran twice the height
657 /// of a window, so the landing is sectioned like the admin panel: a tab row661 /// of a window, so the landing is sectioned like the admin panel: a tab row
658 /// under the wordmark, one section's cards at a time.662 /// under the wordmark, one section's cards at a time.
659-async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {663+async fn signed_in<'a>(cx: &'a Cx, user: im_core::model::User) -> Result<BoxView<'a>> {
660- let lang = lang_of(Some(user));664+ let lang = lang_of(Some(&user));
661 let query = current_query(cx);665 let query = current_query(cx);
662 let section = query_value(&query, "section").unwrap_or_else(|| "profile".to_string());666 let section = query_value(&query, "section").unwrap_or_else(|| "profile".to_string());
663 let ok = query_value(&query, "ok");667 let ok = query_value(&query, "ok");
@@ -692,6 +696,25 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
692 )696 )
693 })697 })
694 .collect::<String>();698 .collect::<String>();
699+ // The stage template moves every value it mentions, so the account's
700+ // template data is staged here as owned values first; the markup below
701+ // never names `user` itself.
702+ let face_button = avatar(cx, &user).await?.first().await?;
703+ let face_plain = avatar(cx, &user).await?.first().await?;
704+ let theme_light = user.theme == "light";
705+ let theme_dark = user.theme == "dark";
706+ let ui_instrument = user.ui == "instrument";
707+ let ui_ledger = user.ui == "ledger";
708+ let lang_en = user.language == "en";
709+ let lang_tr = user.language == "tr";
710+ let timezone_options = timezone_select(&user.timezone);
711+ let email_form = user.email.clone();
712+ let email_shown = user.email.clone();
713+ let display_name = user.name.clone();
714+ let has_photo = user.has_photo;
715+ let totp_on = user.totp_confirmed;
716+ let is_admin = user.admin;
717+ let public_href = format!("/people/{}", user.id);
695 // The family lives in the chrome — the siblings' flyout under the718 // The family lives in the chrome — the siblings' flyout under the
696 // wordmark — and its editing in the admin panel; the landing is the719 // wordmark — and its editing in the admin panel; the landing is the
697 // account's own page and carries no directory of its own.720 // account's own page and carries no directory of its own.
@@ -699,7 +722,7 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
699 cx =>722 cx =>
700 <main class="auth-stage landing-stage">723 <main class="auth-stage landing-stage">
701 <div class="auth-column">724 <div class="auth-column">
702- (family_wordmark(cx).await?)725+ (family_wordmark(cx).await?.first().await?)
703 <nav class="admin-tabs landing-nav">(topcoat::view::Unescaped::new_unchecked(nav))</nav>726 <nav class="admin-tabs landing-nav">(topcoat::view::Unescaped::new_unchecked(nav))</nav>
704 if let Some(code) = ok {727 if let Some(code) = ok {
705 <div class="auth-ok">(ok_text(&code, lang))</div>728 <div class="auth-ok">(ok_text(&code, lang))</div>
@@ -733,28 +756,28 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
733 <label class="auth-field">756 <label class="auth-field">
734 <span class="auth-label">(t(lang, Key::ThemeLabel))</span>757 <span class="auth-label">(t(lang, Key::ThemeLabel))</span>
735 <select class="auth-input" name="theme">758 <select class="auth-input" name="theme">
736- <option value="light" selected=(user.theme == "light")>(t(lang, Key::LightOption))</option>759+ <option value="light" selected=(theme_light)>(t(lang, Key::LightOption))</option>
737- <option value="dark" selected=(user.theme == "dark")>(t(lang, Key::DarkOption))</option>760+ <option value="dark" selected=(theme_dark)>(t(lang, Key::DarkOption))</option>
738 </select>761 </select>
739 </label>762 </label>
740 <label class="auth-field">763 <label class="auth-field">
741 <span class="auth-label">(t(lang, Key::UiLabel))</span>764 <span class="auth-label">(t(lang, Key::UiLabel))</span>
742 <select class="auth-input" name="ui">765 <select class="auth-input" name="ui">
743- <option value="instrument" selected=(user.ui == "instrument")>(t(lang, Key::InstrumentOption))</option>766+ <option value="instrument" selected=(ui_instrument)>(t(lang, Key::InstrumentOption))</option>
744- <option value="ledger" selected=(user.ui == "ledger")>(t(lang, Key::LedgerOption))</option>767+ <option value="ledger" selected=(ui_ledger)>(t(lang, Key::LedgerOption))</option>
745 </select>768 </select>
746 </label>769 </label>
747 <label class="auth-field">770 <label class="auth-field">
748 <span class="auth-label">(t(lang, Key::LanguageLabel))</span>771 <span class="auth-label">(t(lang, Key::LanguageLabel))</span>
749 <select class="auth-input" name="language">772 <select class="auth-input" name="language">
750- <option value="en" selected=(user.language == "en")>"English"</option>773+ <option value="en" selected=(lang_en)>"English"</option>
751- <option value="tr" selected=(user.language == "tr")>"Türkçe"</option>774+ <option value="tr" selected=(lang_tr)>"Türkçe"</option>
752 </select>775 </select>
753 </label>776 </label>
754 <label class="auth-field">777 <label class="auth-field">
755 <span class="auth-label">(t(lang, Key::TimeZoneLabel))</span>778 <span class="auth-label">(t(lang, Key::TimeZoneLabel))</span>
756 <select class="auth-input" name="timezone">779 <select class="auth-input" name="timezone">
757- (topcoat::view::Unescaped::new_unchecked(timezone_select(&user.timezone)))780+ (topcoat::view::Unescaped::new_unchecked(timezone_options))
758 </select>781 </select>
759 </label>782 </label>
760 <button class="auth-submit" type="submit">783 <button class="auth-submit" type="submit">
@@ -823,7 +846,7 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
823 type="email"846 type="email"
824 name="email"847 name="email"
825 autocomplete="email"848 autocomplete="email"
826- value=(user.email.clone())849+ value=(email_form)
827 required=""850 required=""
828 >851 >
829 </label>852 </label>
@@ -837,7 +860,7 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
837 if section != "sessions" && section != "preferences" && section != "password" && section != "apps" {860 if section != "sessions" && section != "preferences" && section != "password" && section != "apps" {
838 <div class="auth-card">861 <div class="auth-card">
839 <div class="profile-head">862 <div class="profile-head">
840- if user.has_photo {863+ if has_photo {
841 // The face is the whole control surface: it opens864 // The face is the whole control surface: it opens
842 // the viewer, and the viewer carries Change/Remove865 // the viewer, and the viewer carries Change/Remove
843 // (avatar_script builds them for a `data-own`866 // (avatar_script builds them for a `data-own`
@@ -850,7 +873,7 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
850 aria-label=(t(lang, Key::ViewPhotoAria))873 aria-label=(t(lang, Key::ViewPhotoAria))
851 data-own=""874 data-own=""
852 >875 >
853- (avatar(cx, user).await?)876+ (face_button)
854 </button>877 </button>
855 <input878 <input
856 id="profile-photo-input"879 id="profile-photo-input"
@@ -866,7 +889,7 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
866 // label wraps the hidden input, which autosubmits889 // label wraps the hidden input, which autosubmits
867 // on change (avatar_script) — no buttons at all.890 // on change (avatar_script) — no buttons at all.
868 <label class="profile-avatar-upload">891 <label class="profile-avatar-upload">
869- (avatar(cx, user).await?)892+ (face_plain)
870 <input893 <input
871 class="profile-file-hidden"894 class="profile-file-hidden"
872 type="file"895 type="file"
@@ -878,14 +901,14 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
878 </label>901 </label>
879 }902 }
880 <div class="profile-heading">903 <div class="profile-heading">
881- <div class="auth-title">(user.name.clone())</div>904+ <div class="auth-title">(display_name)</div>
882 <div class="profile-marks">905 <div class="profile-marks">
883- if user.totp_confirmed {906+ if totp_on {
884 <span class="chip chip-connected">(t(lang, Key::TwoFaOn))</span>907 <span class="chip chip-connected">(t(lang, Key::TwoFaOn))</span>
885 } else {908 } else {
886 <span class="chip chip-muted">(t(lang, Key::TwoFaOff))</span>909 <span class="chip chip-muted">(t(lang, Key::TwoFaOff))</span>
887 }910 }
888- if user.admin {911+ if is_admin {
889 <span class="chip chip-accent">(t(lang, Key::AdminChip))</span>912 <span class="chip chip-accent">(t(lang, Key::AdminChip))</span>
890 }913 }
891 </div>914 </div>
@@ -894,18 +917,18 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
894 <dl class="profile-fields">917 <dl class="profile-fields">
895 <div class="profile-field">918 <div class="profile-field">
896 <dt class="auth-label">(t(lang, Key::EmailLabel))</dt>919 <dt class="auth-label">(t(lang, Key::EmailLabel))</dt>
897- <dd class="profile-value mono">(user.email.clone())</dd>920+ <dd class="profile-value mono">(email_shown)</dd>
898 </div>921 </div>
899 <div class="profile-field">922 <div class="profile-field">
900 <dt class="auth-label">(t(lang, Key::MemberSinceLabel))</dt>923 <dt class="auth-label">(t(lang, Key::MemberSinceLabel))</dt>
901 <dd class="profile-value">(joined)</dd>924 <dd class="profile-value">(joined)</dd>
902 </div>925 </div>
903 </dl>926 </dl>
904- <a class="auth-alt" href=(format!("/people/{}", user.id))>(t(lang, Key::PublicProfileLink))</a>927+ <a class="auth-alt" href=(public_href)>(t(lang, Key::PublicProfileLink))</a>
905- if !user.totp_confirmed {928+ if !totp_on {
906 <a class="auth-alt" href="/enroll">(t(lang, Key::Activate2fa))</a>929 <a class="auth-alt" href="/enroll">(t(lang, Key::Activate2fa))</a>
907 }930 }
908- if user.admin {931+ if is_admin {
909 <a class="auth-alt" href="/admin">(t(lang, Key::AdminPanelLink))</a>932 <a class="auth-alt" href="/admin">(t(lang, Key::AdminPanelLink))</a>
910 }933 }
911 // Both forms carry no visible chrome of their own: the934 // Both forms carry no visible chrome of their own: the
@@ -917,7 +940,7 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
917 action="/api/profile_photo"940 action="/api/profile_photo"
918 enctype="multipart/form-data"941 enctype="multipart/form-data"
919 ></form>942 ></form>
920- if user.has_photo {943+ if has_photo {
921 <form944 <form
922 id="profile-photo-remove"945 id="profile-photo-remove"
923 method="post"946 method="post"
@@ -945,15 +968,15 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
945 <div class="auth-footer">(t(lang, Key::BrandFooter))</div>968 <div class="auth-footer">(t(lang, Key::BrandFooter))</div>
946 </div>969 </div>
947 </main>970 </main>
948- (crate::layout::avatar_script(cx, lang).await?)971+ (crate::layout::avatar_script(cx, lang).await?.first().await?)
949 };972 };
950- shell(cx, "im", Some(user), stage).await973+ shell(cx, "im", Some(user), Child::new(stage)).await.map(ViewExt::boxed)
951 }974 }
952 975
953 /// "Forgot it?" — the self-serve reset ask. It answers the same whether the976 /// "Forgot it?" — the self-serve reset ask. It answers the same whether the
954 /// address has an account: one quiet note, the same one for every address.977 /// address has an account: one quiet note, the same one for every address.
955 #[page("/forgot")]978 #[page("/forgot")]
956-async fn forgot(cx: &Cx) -> Result {979+async fn forgot(cx: &Cx) -> Result<impl View + '_> {
957 let lang = Lang::En;980 let lang = Lang::En;
958 let query = current_query(cx);981 let query = current_query(cx);
959 let error = query_value(&query, "error");982 let error = query_value(&query, "error");
@@ -962,7 +985,7 @@ async fn forgot(cx: &Cx) -> Result {
962 cx =>985 cx =>
963 <main class="auth-stage">986 <main class="auth-stage">
964 <div class="auth-column">987 <div class="auth-column">
965- (wordmark(cx).await?)988+ (wordmark(cx).await?.first().await?)
966 <div class="auth-card">989 <div class="auth-card">
967 <div class="auth-head">990 <div class="auth-head">
968 <div class="auth-title">(t(lang, Key::ForgotTitle))</div>991 <div class="auth-title">(t(lang, Key::ForgotTitle))</div>
@@ -995,7 +1018,7 @@ async fn forgot(cx: &Cx) -> Result {
995 </div>1018 </div>
996 </main>1019 </main>
997 };1020 };
998- shell(cx, t(lang, Key::TitleForgot), None, stage).await1021+ shell(cx, t(lang, Key::TitleForgot), None, Child::new(stage)).await
999 }1022 }
1000 1023
1001 /// The reset link's destination: a new password, twice. A dead link never1024 /// The reset link's destination: a new password, twice. A dead link never
@@ -1013,7 +1036,7 @@ async fn reset_page(cx: &Cx) -> Result<Response> {
1013 cx =>1036 cx =>
1014 <main class="auth-stage">1037 <main class="auth-stage">
1015 <div class="auth-column">1038 <div class="auth-column">
1016- (wordmark(cx).await?)1039+ (wordmark(cx).await?.first().await?)
1017 <div class="auth-card">1040 <div class="auth-card">
1018 <div class="auth-head">1041 <div class="auth-head">
1019 <div class="auth-title">(t(lang, Key::ResetTitle))</div>1042 <div class="auth-title">(t(lang, Key::ResetTitle))</div>
@@ -1055,7 +1078,9 @@ async fn reset_page(cx: &Cx) -> Result<Response> {
1055 </div>1078 </div>
1056 </main>1079 </main>
1057 };1080 };
1058- shell(cx, t(lang, Key::TitleReset), None, stage)1081+ shell(cx, t(lang, Key::TitleReset), None, Child::new(stage))
1082+ .await?
1083+ .first()
1059 .await?1084 .await?
1060 .into_response(cx)1085 .into_response(cx)
1061 }1086 }
@@ -1075,7 +1100,7 @@ async fn email_change_page(cx: &Cx) -> Result<Response> {
1075 cx =>1100 cx =>
1076 <main class="auth-stage">1101 <main class="auth-stage">
1077 <div class="auth-column">1102 <div class="auth-column">
1078- (wordmark(cx).await?)1103+ (wordmark(cx).await?.first().await?)
1079 <div class="auth-card">1104 <div class="auth-card">
1080 <div class="auth-head">1105 <div class="auth-head">
1081 <div class="auth-title">(t(lang, Key::EmailConfirmTitle))</div>1106 <div class="auth-title">(t(lang, Key::EmailConfirmTitle))</div>
@@ -1094,7 +1119,9 @@ async fn email_change_page(cx: &Cx) -> Result<Response> {
1094 </div>1119 </div>
1095 </main>1120 </main>
1096 };1121 };
1097- shell(cx, t(lang, Key::EmailConfirmTitle), None, stage)1122+ shell(cx, t(lang, Key::EmailConfirmTitle), None, Child::new(stage))
1123+ .await?
1124+ .first()
1098 .await?1125 .await?
1099 .into_response(cx)1126 .into_response(cx)
1100 }1127 }
crates/im-web/src/people.rsmodified+23 -12
@@ -9,7 +9,7 @@ use topcoat::Result;
9 use topcoat::context::Cx;9 use topcoat::context::Cx;
10 use topcoat::router::error::not_found;10 use topcoat::router::error::not_found;
11 use topcoat::router::{page, path_param};11 use topcoat::router::{page, path_param};
12-use topcoat::view::view;12+use topcoat::view::{Child, View, ViewExt, view};
13 13
14 use im_core::accounts;14 use im_core::accounts;
15 15
@@ -21,7 +21,7 @@ path_param!(user_id);
21 21
22 /// A person's page. `/people/{user_id}`.22 /// A person's page. `/people/{user_id}`.
23 #[page("/people/{user_id}")]23 #[page("/people/{user_id}")]
24-async fn people_page(cx: &Cx) -> Result {24+async fn people_page(cx: &Cx) -> Result<impl View + '_> {
25 let Some(viewer) = server::current_user(cx).await else {25 let Some(viewer) = server::current_user(cx).await else {
26 return Err(not_found().into());26 return Err(not_found().into());
27 };27 };
@@ -35,31 +35,42 @@ async fn people_page(cx: &Cx) -> Result {
35 let mine = person.id == viewer.id;35 let mine = person.id == viewer.id;
36 let stats = im_core::stats::profile_stats(&store, &person.id).await?;36 let stats = im_core::stats::profile_stats(&store, &person.id).await?;
37 let joined = person.created_at.date().to_string();37 let joined = person.created_at.date().to_string();
38+ // The stage template moves every value it mentions, so the account's
39+ // template data is staged here as owned values first; the markup below
40+ // never names `person` itself.
41+ let face_button = avatar(cx, &person).await?.first().await?;
42+ let face_plain = avatar(cx, &person).await?.first().await?;
43+ let display_name = person.name.clone();
44+ let email_shown = person.email.clone();
45+ let has_photo = person.has_photo;
46+ let totp_on = person.totp_confirmed;
47+ let is_admin = person.admin;
48+ let profile_title = format!("{} · im", person.name);
38 let stage = view! {49 let stage = view! {
39 cx =>50 cx =>
40 <main class="auth-stage">51 <main class="auth-stage">
41 <div class="auth-column">52 <div class="auth-column">
42- (family_wordmark(cx).await?)53+ (family_wordmark(cx).await?.first().await?)
43 <div class="auth-card">54 <div class="auth-card">
44 <div class="profile-head">55 <div class="profile-head">
45- if person.has_photo {56+ if has_photo {
46 // The face opens the viewer here too — same as57 // The face opens the viewer here too — same as
47 // the landing, same as iz's person page.58 // the landing, same as iz's person page.
48 <button class="avatar-view" type="button" aria-label=(t(lang, Key::ViewPhotoAria))>59 <button class="avatar-view" type="button" aria-label=(t(lang, Key::ViewPhotoAria))>
49- (avatar(cx, &person).await?)60+ (face_button)
50 </button>61 </button>
51 } else {62 } else {
52- (avatar(cx, &person).await?)63+ (face_plain)
53 }64 }
54 <div class="profile-heading">65 <div class="profile-heading">
55- <div class="auth-title">(person.name.clone())</div>66+ <div class="auth-title">(display_name)</div>
56 <div class="profile-marks">67 <div class="profile-marks">
57- if person.totp_confirmed {68+ if totp_on {
58 <span class="chip chip-connected">(t(lang, Key::TwoFaOn))</span>69 <span class="chip chip-connected">(t(lang, Key::TwoFaOn))</span>
59 } else {70 } else {
60 <span class="chip chip-muted">(t(lang, Key::TwoFaOff))</span>71 <span class="chip chip-muted">(t(lang, Key::TwoFaOff))</span>
61 }72 }
62- if person.admin {73+ if is_admin {
63 <span class="chip chip-accent">(t(lang, Key::AdminChip))</span>74 <span class="chip chip-accent">(t(lang, Key::AdminChip))</span>
64 }75 }
65 </div>76 </div>
@@ -68,7 +79,7 @@ async fn people_page(cx: &Cx) -> Result {
68 <dl class="profile-fields">79 <dl class="profile-fields">
69 <div class="profile-field">80 <div class="profile-field">
70 <dt class="auth-label">(t(lang, Key::EmailLabel))</dt>81 <dt class="auth-label">(t(lang, Key::EmailLabel))</dt>
71- <dd class="profile-value mono">(person.email.clone())</dd>82+ <dd class="profile-value mono">(email_shown)</dd>
72 </div>83 </div>
73 <div class="profile-field">84 <div class="profile-field">
74 <dt class="auth-label">(t(lang, Key::MemberSinceLabel))</dt>85 <dt class="auth-label">(t(lang, Key::MemberSinceLabel))</dt>
@@ -98,7 +109,7 @@ async fn people_page(cx: &Cx) -> Result {
98 <div class="auth-footer">(t(lang, Key::BrandFooter))</div>109 <div class="auth-footer">(t(lang, Key::BrandFooter))</div>
99 </div>110 </div>
100 </main>111 </main>
101- (crate::layout::avatar_script(cx, lang).await?)112+ (crate::layout::avatar_script(cx, lang).await?.first().await?)
102 };113 };
103- shell(cx, &format!("{} · im", person.name), Some(&viewer), stage).await114+ shell(cx, profile_title, Some(viewer), Child::new(stage)).await
104 }115 }
crates/im-web/src/server.rsmodified+2 -2
@@ -86,8 +86,8 @@ const SHOWN_TTL: Duration = Duration::from_secs(10 * 60);
86 /// page's read takes it out (`take_shown_secret`), and a replayed or86 /// page's read takes it out (`take_shown_secret`), and a replayed or
87 /// reloaded URL finds the shelf empty and renders no secret at all. A87 /// reloaded URL finds the shelf empty and renders no secret at all. A
88 /// restart drops the shelf — the admin mints another, as with the CLI.88 /// restart drops the shelf — the admin mints another, as with the CLI.
89-static SHOWN_SECRETS: LazyLock<Mutex<HashMap<String, ((String, String), Instant)>>> =89+type ShownShelf = HashMap<String, ((String, String), Instant)>;
90- LazyLock::new(|| Mutex::new(HashMap::new()));90+static SHOWN_SECRETS: LazyLock<Mutex<ShownShelf>> = LazyLock::new(|| Mutex::new(HashMap::new()));
91 91
92 /// Parks a client's fresh pair on the shelf and returns the claim ticket92 /// Parks a client's fresh pair on the shelf and returns the claim ticket
93 /// for its URL. The id travels too — it is the public half of the pair and93 /// for its URL. The id travels too — it is the public half of the pair and