diff --git a/.github/workflows/update_deps.mjs b/.github/workflows/update_deps.mjs index 58565463..2b39f8da 100644 --- a/.github/workflows/update_deps.mjs +++ b/.github/workflows/update_deps.mjs @@ -28,9 +28,6 @@ export async function getUpdates() { if (currentVersion.includes('-next')) { tag = 'next'; } - if (currentVersion.includes('8.0.0-alpha')) { - tag = 'rc-v8'; - } let prefix = currentVersion[0]; if (prefix !== '^' && prefix !== '~') { prefix = ''; diff --git a/Cargo.lock b/Cargo.lock index 23741dba..b569aaab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -53,9 +53,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" [[package]] name = "autocfg" @@ -141,7 +141,7 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "create-o7-app" -version = "0.8.13" +version = "0.9.0" dependencies = [ "anyhow", "clap", @@ -366,9 +366,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libredox" @@ -466,9 +466,9 @@ dependencies = [ [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" [[package]] name = "percent-encoding" @@ -478,9 +478,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -570,9 +570,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -624,9 +624,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.79" +version = "2.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index eb2c9e83..933ab6bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "create-o7-app" authors = ["Ottomated"] -version = "0.8.13" +version = "0.9.0" edition = "2021" [dependencies] diff --git a/telemetry-server/package.json b/telemetry-server/package.json index c768f13b..520dbf40 100644 --- a/telemetry-server/package.json +++ b/telemetry-server/package.json @@ -9,9 +9,9 @@ "cf-typegen": "wrangler types" }, "devDependencies": { - "@cloudflare/workers-types": "^4.20240712.0", - "typescript": "^5.5.2", - "wrangler": "^3.60.3" + "@cloudflare/workers-types": "^4.20241018.0", + "typescript": "^5.6.3", + "wrangler": "^3.81.0" }, "dependencies": { "zod": "^3.23.8" diff --git a/telemetry-server/pnpm-lock.yaml b/telemetry-server/pnpm-lock.yaml index ebb7b332..f539536d 100644 --- a/telemetry-server/pnpm-lock.yaml +++ b/telemetry-server/pnpm-lock.yaml @@ -13,14 +13,14 @@ importers: version: 3.23.8 devDependencies: '@cloudflare/workers-types': - specifier: ^4.20240712.0 - version: 4.20240712.0 + specifier: ^4.20241018.0 + version: 4.20241018.0 typescript: - specifier: ^5.5.2 - version: 5.5.3 + specifier: ^5.6.3 + version: 5.6.3 wrangler: - specifier: ^3.60.3 - version: 3.65.0(@cloudflare/workers-types@4.20240712.0) + specifier: ^3.81.0 + version: 3.81.0(@cloudflare/workers-types@4.20241018.0) packages: @@ -28,38 +28,42 @@ packages: resolution: {integrity: sha512-YLPHc8yASwjNkmcDMQMY35yiWjoKAKnhUbPRszBRS0YgH+IXtsMp61j+yTcnCE3oO2DgP0U3iejLC8FTtKDC8Q==} engines: {node: '>=16.13'} - '@cloudflare/workerd-darwin-64@1.20240712.0': - resolution: {integrity: sha512-KB1vbOhr62BCAwVr3VaRcngzPeSCQ7zPA9VGrfwYXIxo0Y4zlW1z0EVtcewFSz5XXKr3BtNnJXxdjDPUNkguQw==} + '@cloudflare/workerd-darwin-64@1.20241011.1': + resolution: {integrity: sha512-gZ2PrMCQ4WdDCB+V6vsB2U2SyYcmgaGMEa3GGjcUfC79L/8so3Vp/bO0eCoLmvttRs39wascZ+JiWL0HpcZUgA==} engines: {node: '>=16'} cpu: [x64] os: [darwin] - '@cloudflare/workerd-darwin-arm64@1.20240712.0': - resolution: {integrity: sha512-UDwFnCfQGFVCNxOeHxKNEc1ANQk/3OIiFWpVsxgZqJqU/22XM88JHxJW+YcBKsaUGUlpLyImaYUn2/rG+i+9UQ==} + '@cloudflare/workerd-darwin-arm64@1.20241011.1': + resolution: {integrity: sha512-c26TYtS0e3WZ09nL/a8YaEqveCsTlgDm12ehPMNua9u68sh1KzETMl2G45O934m8UrI3Rhpv2TTecO0S5b9exA==} engines: {node: '>=16'} cpu: [arm64] os: [darwin] - '@cloudflare/workerd-linux-64@1.20240712.0': - resolution: {integrity: sha512-MxpMHSJcZRUL66TO7BEnEim9WgZ8wJEVOB1Rq7a/IF2hI4/8f+N+02PChh62NkBlWxDfTXAtZy0tyQMm0EGjHg==} + '@cloudflare/workerd-linux-64@1.20241011.1': + resolution: {integrity: sha512-pl4xvHNXnm3cYh5GwHadOTQRWt4Ih/gzCOb6RW4n78oNQQydFvpwqYAjbYk32y485feLhdTKXut/MgZAyWnKyQ==} engines: {node: '>=16'} cpu: [x64] os: [linux] - '@cloudflare/workerd-linux-arm64@1.20240712.0': - resolution: {integrity: sha512-DtLYZsFFFAMgn+6YCHoQS6nYY4nbdAtcAFa4PhWTjLJDbvQEn3IoK9Bi4ajCL7xG36FeuBdZliSbBiiv7CJjfQ==} + '@cloudflare/workerd-linux-arm64@1.20241011.1': + resolution: {integrity: sha512-I4HAF2Qe8xgIjAdE53viT2fDdHXkrb3Be0L3eWeeP5SEkOtQ4cHLqsOV7yhUWOJpHiI1XCDcf+wdfn0PB/EngQ==} engines: {node: '>=16'} cpu: [arm64] os: [linux] - '@cloudflare/workerd-windows-64@1.20240712.0': - resolution: {integrity: sha512-u8zoT9PQiiwxuz9npquLBFWrC/RlBWGGZ1aylarZNFlM4sFrRm+bRr6i+KtS+fltHIVXj3teuoKYytA1ppf9Yw==} + '@cloudflare/workerd-windows-64@1.20241011.1': + resolution: {integrity: sha512-oVr1Cb7NkDpukd7v68FdxOH8vaHRSzHkX9uE/IttHd2yPK6mwOS220nIxK9UMcx5CwZmrgphRwtZwSYVk/lREQ==} engines: {node: '>=16'} cpu: [x64] os: [win32] - '@cloudflare/workers-types@4.20240712.0': - resolution: {integrity: sha512-C+C0ZnkRrxR2tPkZKAXwBsWEse7bWaA7iMbaG6IKaxaPTo/5ilx7Ei3BkI2izxmOJMsC05VS1eFUf95urXzhmw==} + '@cloudflare/workers-shared@0.6.0': + resolution: {integrity: sha512-rfUCvb3hx4AsvdUZsxgk9lmgEnQehqV3jdtXLP/Xr0+P56n11T/0nXNMzmn7Nnv+IJFOV6X9NmFhuMz4sBPw7w==} + engines: {node: '>=16.7.0'} + + '@cloudflare/workers-types@4.20241018.0': + resolution: {integrity: sha512-gGWumpaaqnjN/G6SI7CZQ13G4SpIUV+EM8QqvuN2D3cGDF6mKIm+ov7H4x7V/c+AdY90v0FCc8B5nmEEt90MvQ==} '@cspotcode/source-map-support@0.8.1': resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} @@ -224,15 +228,15 @@ packages: '@types/node-forge@1.3.11': resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==} - '@types/node@20.14.11': - resolution: {integrity: sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==} + '@types/node@22.7.7': + resolution: {integrity: sha512-SRxCrrg9CL/y54aiMCG3edPKdprgMVGDXjA3gB8UmmBW5TcXzRUYAh8EWzTnSJFAd1rgImPELza+A3bJ+qxz8Q==} - acorn-walk@8.3.3: - resolution: {integrity: sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==} + acorn-walk@8.3.4: + resolution: {integrity: sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==} engines: {node: '>=0.4.0'} - acorn@8.12.1: - resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==} + acorn@8.13.0: + resolution: {integrity: sha512-8zSiw54Oxrdym50NlZ9sUusyO1Z1ZchgRLWRaK6c86XJFClyCgFKetdowBg5bKxyp/u+CDBJG4Mpp0m3HLZl9w==} engines: {node: '>=0.4.0'} hasBin: true @@ -261,22 +265,15 @@ packages: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} - consola@3.2.3: - resolution: {integrity: sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==} - engines: {node: ^14.18.0 || >=16.10.0} - - cookie@0.5.0: - resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} + cookie@0.7.2: + resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} engines: {node: '>= 0.6'} data-uri-to-buffer@2.0.2: resolution: {integrity: sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==} - date-fns@3.6.0: - resolution: {integrity: sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==} - - debug@4.3.5: - resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} + debug@4.3.7: + resolution: {integrity: sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==} engines: {node: '>=6.0'} peerDependencies: supports-color: '*' @@ -333,8 +330,8 @@ packages: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} - is-core-module@2.15.0: - resolution: {integrity: sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==} + is-core-module@2.15.1: + resolution: {integrity: sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==} engines: {node: '>= 0.4'} is-extglob@2.1.1: @@ -357,13 +354,13 @@ packages: engines: {node: '>=10.0.0'} hasBin: true - miniflare@3.20240712.0: - resolution: {integrity: sha512-zVbsMX2phvJS1uTPmjK6CvVBq4ON2UkmvTw9IMfNPACsWJmHEdsBDxsYEG1vKAduJdI5gULLuJf7qpFxByDhGw==} + miniflare@3.20241011.0: + resolution: {integrity: sha512-Mb3U9+QvKgIUl9LgHwBxEz8WajMRYqO5mMHRtO8yHjNCLGh24I6Ts9z13zRAYGPDd1xBQ1o983fHT9S+tn6r+A==} engines: {node: '>=16.13'} hasBin: true - ms@2.1.2: - resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} mustache@4.2.0: resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==} @@ -374,9 +371,6 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - node-fetch-native@1.6.4: - resolution: {integrity: sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==} - node-forge@1.3.1: resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==} engines: {node: '>= 6.13.0'} @@ -385,11 +379,14 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} + ohash@1.1.4: + resolution: {integrity: sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==} + path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} - path-to-regexp@6.2.2: - resolution: {integrity: sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==} + path-to-regexp@6.3.0: + resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} @@ -450,38 +447,38 @@ packages: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} - tslib@2.6.3: - resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==} + tslib@2.8.0: + resolution: {integrity: sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==} - typescript@5.5.3: - resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==} + typescript@5.6.3: + resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==} engines: {node: '>=14.17'} hasBin: true ufo@1.5.4: resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==} - undici-types@5.26.5: - resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + undici-types@6.19.8: + resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} undici@5.28.4: resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==} engines: {node: '>=14.0'} - unenv-nightly@1.10.0-1717606461.a117952: - resolution: {integrity: sha512-u3TfBX02WzbHTpaEfWEKwDijDSFAHcgXkayUZ+MVDrjhLFvgAJzFGTSTmwlEhwWi2exyRQey23ah9wELMM6etg==} + unenv-nightly@2.0.0-20241009-125958-e8ea22f: + resolution: {integrity: sha512-hRxmKz1iSVRmuFx/vBdPsx7rX4o7Cas9vdjDNeUeWpQTK2LzU3Xy3Jz0zbo7MJX0bpqo/LEFCA+GPwsbl6zKEQ==} - workerd@1.20240712.0: - resolution: {integrity: sha512-hdIHZif82hBDy9YnMtcmDGgbLU5f2P2aGpi/X8EKhTSLDppVUGrkY3XB536J4jGjA2D5dS0FUEXCl5bAJEed8Q==} + workerd@1.20241011.1: + resolution: {integrity: sha512-ORobT1XDkE+p+36yk6Szyw68bWuGSmuwIlDnAeUOfnYunb/Txt0jg7ydzfwr4UIsof7AH5F1nqZms5PWLu05yw==} engines: {node: '>=16'} hasBin: true - wrangler@3.65.0: - resolution: {integrity: sha512-IDy4ttyJZssazAd5CXHw4NWeZFGxngdNF5m2ogltdT3CV7uHfCvPVdMcr4uNMpRZd0toHmAE3LtQeXxDFFp88A==} + wrangler@3.81.0: + resolution: {integrity: sha512-sa5dhLJAMmYtl/dJWDJ92sdnKj0VUC0DYBfGqbhd5xn7CDdn1oGhICDXtx2E6BNhQ1L+4d9oAcP/oQvOs5gKLA==} engines: {node: '>=16.17.0'} hasBin: true peerDependencies: - '@cloudflare/workers-types': ^4.20240712.0 + '@cloudflare/workers-types': ^4.20241011.0 peerDependenciesMeta: '@cloudflare/workers-types': optional: true @@ -501,8 +498,8 @@ packages: xxhash-wasm@1.0.2: resolution: {integrity: sha512-ibF0Or+FivM9lNrg+HGJfVX8WJqgo+kCLDc4vx6xMeTce7Aj+DLttKbxxRR/gNLSAelRc1omAPlJ77N/Jem07A==} - youch@3.3.3: - resolution: {integrity: sha512-qSFXUk3UZBLfggAW3dJKg0BMblG5biqSF8M34E06o5CSsZtH92u9Hqmj2RzGiHDi64fhe83+4tENFP2DB6t6ZA==} + youch@3.3.4: + resolution: {integrity: sha512-UeVBXie8cA35DS6+nBkls68xaBBXCye0CNznrhszZjTbRVnJKQuNsyLKBTTL4ln1o1rh2PKtv35twV7irj5SEg==} zod@3.23.8: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} @@ -513,22 +510,27 @@ snapshots: dependencies: mime: 3.0.0 - '@cloudflare/workerd-darwin-64@1.20240712.0': + '@cloudflare/workerd-darwin-64@1.20241011.1': optional: true - '@cloudflare/workerd-darwin-arm64@1.20240712.0': + '@cloudflare/workerd-darwin-arm64@1.20241011.1': optional: true - '@cloudflare/workerd-linux-64@1.20240712.0': + '@cloudflare/workerd-linux-64@1.20241011.1': optional: true - '@cloudflare/workerd-linux-arm64@1.20240712.0': + '@cloudflare/workerd-linux-arm64@1.20241011.1': optional: true - '@cloudflare/workerd-windows-64@1.20240712.0': + '@cloudflare/workerd-windows-64@1.20241011.1': optional: true - '@cloudflare/workers-types@4.20240712.0': {} + '@cloudflare/workers-shared@0.6.0': + dependencies: + mime: 3.0.0 + zod: 3.23.8 + + '@cloudflare/workers-types@4.20241018.0': {} '@cspotcode/source-map-support@0.8.1': dependencies: @@ -623,17 +625,17 @@ snapshots: '@types/node-forge@1.3.11': dependencies: - '@types/node': 20.14.11 + '@types/node': 22.7.7 - '@types/node@20.14.11': + '@types/node@22.7.7': dependencies: - undici-types: 5.26.5 + undici-types: 6.19.8 - acorn-walk@8.3.3: + acorn-walk@8.3.4: dependencies: - acorn: 8.12.1 + acorn: 8.13.0 - acorn@8.12.1: {} + acorn@8.13.0: {} anymatch@3.1.3: dependencies: @@ -654,8 +656,8 @@ snapshots: capnp-ts@0.7.0: dependencies: - debug: 4.3.5 - tslib: 2.6.3 + debug: 4.3.7 + tslib: 2.8.0 transitivePeerDependencies: - supports-color @@ -671,17 +673,13 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - consola@3.2.3: {} - - cookie@0.5.0: {} + cookie@0.7.2: {} data-uri-to-buffer@2.0.2: {} - date-fns@3.6.0: {} - - debug@4.3.5: + debug@4.3.7: dependencies: - ms: 2.1.2 + ms: 2.1.3 defu@6.1.4: {} @@ -744,7 +742,7 @@ snapshots: dependencies: binary-extensions: 2.3.0 - is-core-module@2.15.0: + is-core-module@2.15.1: dependencies: hasown: 2.0.2 @@ -762,40 +760,40 @@ snapshots: mime@3.0.0: {} - miniflare@3.20240712.0: + miniflare@3.20241011.0: dependencies: '@cspotcode/source-map-support': 0.8.1 - acorn: 8.12.1 - acorn-walk: 8.3.3 + acorn: 8.13.0 + acorn-walk: 8.3.4 capnp-ts: 0.7.0 exit-hook: 2.2.1 glob-to-regexp: 0.4.1 stoppable: 1.1.0 undici: 5.28.4 - workerd: 1.20240712.0 + workerd: 1.20241011.1 ws: 8.18.0 - youch: 3.3.3 + youch: 3.3.4 zod: 3.23.8 transitivePeerDependencies: - bufferutil - supports-color - utf-8-validate - ms@2.1.2: {} + ms@2.1.3: {} mustache@4.2.0: {} nanoid@3.3.7: {} - node-fetch-native@1.6.4: {} - node-forge@1.3.1: {} normalize-path@3.0.0: {} + ohash@1.1.4: {} + path-parse@1.0.7: {} - path-to-regexp@6.2.2: {} + path-to-regexp@6.3.0: {} pathe@1.1.2: {} @@ -811,7 +809,7 @@ snapshots: resolve@1.22.8: dependencies: - is-core-module: 2.15.0 + is-core-module: 2.15.1 path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 @@ -851,55 +849,54 @@ snapshots: dependencies: is-number: 7.0.0 - tslib@2.6.3: {} + tslib@2.8.0: {} - typescript@5.5.3: {} + typescript@5.6.3: {} ufo@1.5.4: {} - undici-types@5.26.5: {} + undici-types@6.19.8: {} undici@5.28.4: dependencies: '@fastify/busboy': 2.1.1 - unenv-nightly@1.10.0-1717606461.a117952: + unenv-nightly@2.0.0-20241009-125958-e8ea22f: dependencies: - consola: 3.2.3 defu: 6.1.4 - mime: 3.0.0 - node-fetch-native: 1.6.4 + ohash: 1.1.4 pathe: 1.1.2 ufo: 1.5.4 - workerd@1.20240712.0: + workerd@1.20241011.1: optionalDependencies: - '@cloudflare/workerd-darwin-64': 1.20240712.0 - '@cloudflare/workerd-darwin-arm64': 1.20240712.0 - '@cloudflare/workerd-linux-64': 1.20240712.0 - '@cloudflare/workerd-linux-arm64': 1.20240712.0 - '@cloudflare/workerd-windows-64': 1.20240712.0 + '@cloudflare/workerd-darwin-64': 1.20241011.1 + '@cloudflare/workerd-darwin-arm64': 1.20241011.1 + '@cloudflare/workerd-linux-64': 1.20241011.1 + '@cloudflare/workerd-linux-arm64': 1.20241011.1 + '@cloudflare/workerd-windows-64': 1.20241011.1 - wrangler@3.65.0(@cloudflare/workers-types@4.20240712.0): + wrangler@3.81.0(@cloudflare/workers-types@4.20241018.0): dependencies: '@cloudflare/kv-asset-handler': 0.3.4 + '@cloudflare/workers-shared': 0.6.0 '@esbuild-plugins/node-globals-polyfill': 0.2.3(esbuild@0.17.19) '@esbuild-plugins/node-modules-polyfill': 0.2.2(esbuild@0.17.19) blake3-wasm: 2.1.5 chokidar: 3.6.0 - date-fns: 3.6.0 esbuild: 0.17.19 - miniflare: 3.20240712.0 + miniflare: 3.20241011.0 nanoid: 3.3.7 - path-to-regexp: 6.2.2 + path-to-regexp: 6.3.0 resolve: 1.22.8 resolve.exports: 2.0.2 selfsigned: 2.4.1 source-map: 0.6.1 - unenv: unenv-nightly@1.10.0-1717606461.a117952 + unenv: unenv-nightly@2.0.0-20241009-125958-e8ea22f + workerd: 1.20241011.1 xxhash-wasm: 1.0.2 optionalDependencies: - '@cloudflare/workers-types': 4.20240712.0 + '@cloudflare/workers-types': 4.20241018.0 fsevents: 2.3.3 transitivePeerDependencies: - bufferutil @@ -910,9 +907,9 @@ snapshots: xxhash-wasm@1.0.2: {} - youch@3.3.3: + youch@3.3.4: dependencies: - cookie: 0.5.0 + cookie: 0.7.2 mustache: 4.2.0 stacktracey: 2.1.8 diff --git a/template_builder/templates/base/.prettierrc b/template_builder/templates/base/.prettierrc index 18cd92df..95d76e71 100644 --- a/template_builder/templates/base/.prettierrc +++ b/template_builder/templates/base/.prettierrc @@ -5,7 +5,8 @@ "useTabs": true, "trailingComma": "all", "plugins": [ - "prettier-plugin-svelte" + "prettier-plugin-svelte", + "prettier-plugin-tailwindcss" ], "overrides": [ { diff --git a/template_builder/templates/base/package.json b/template_builder/templates/base/package.json index 2b1f913b..f2cb9d49 100644 --- a/template_builder/templates/base/package.json +++ b/template_builder/templates/base/package.json @@ -10,26 +10,26 @@ }, "dependencies": {}, "devDependencies": { - "@eslint/js": "^9.12.0", + "@eslint/js": "^9.13.0", "@sveltejs/adapter-auto": "^3.2.5", - "@sveltejs/kit": "^2.6.4", - "@sveltejs/vite-plugin-svelte": "^3.1.2", + "@sveltejs/kit": "^2.7.2", + "@sveltejs/vite-plugin-svelte": "^4.0.0", "autoprefixer": "^10.4.20", - "eslint": "^9.12.0", + "eslint": "^9.13.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", - "eslint-plugin-svelte": "^2.44.1", + "eslint-plugin-svelte": "^2.46.0", "globals": "^15.11.0", "postcss": "^8.4.47", "postcss-load-config": "^6.0.1", "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.7", "prettier-plugin-tailwindcss": "^0.6.8", - "svelte": "^4.2.19", - "svelte-check": "^4.0.4", - "tailwindcss": "^3.4.13", + "svelte": "^5.0.5", + "svelte-check": "^4.0.5", + "tailwindcss": "^3.4.14", "typescript": "~5.6.3", - "typescript-eslint": "^8.0.0-alpha.62", - "vite": "^5.4.8" + "typescript-eslint": "^8.11.0", + "vite": "^5.4.9" } } diff --git a/template_builder/templates/base/src/lib/components/NextStep.svelte b/template_builder/templates/base/src/lib/components/NextStep.svelte index 7dbc37cb..a788b3e4 100644 --- a/template_builder/templates/base/src/lib/components/NextStep.svelte +++ b/template_builder/templates/base/src/lib/components/NextStep.svelte @@ -1,11 +1,20 @@

{title}

- + {@render children()} import '../app.css'; + + const { children } = $props(); - +{@render children()} diff --git a/template_builder/templates/config.json b/template_builder/templates/config.json index 3c6a00ae..b8055e2c 100644 --- a/template_builder/templates/config.json +++ b/template_builder/templates/config.json @@ -56,11 +56,6 @@ "description": "(Additional worker for websockets, etc.)", "hidden_if_not": ["Edge"], "default": false - }, - { - "id": "Svelte5", - "name": "Svelte 5", - "description": "(in preview)" } ] } diff --git a/template_builder/templates/extras/src/lib/auth/{Auth}index.ts b/template_builder/templates/extras/src/lib/auth/{Auth}index.ts new file mode 100644 index 00000000..25b1230a --- /dev/null +++ b/template_builder/templates/extras/src/lib/auth/{Auth}index.ts @@ -0,0 +1,106 @@ +import { Twitch } from 'arctic'; +import { Base32Encoding, encodeHex } from 'oslo/encoding'; +import { generateRandomString, sha256 } from 'oslo/crypto'; +import type { Selectable } from 'kysely'; +import { db } from '$lib/db'; +import { CLIENT_ID, CLIENT_SECRET } from '$env/static/private'; +import type { DB } from '$lib/db/schema'; + +const ONE_DAY = 1000 * 60 * 60 * 24; +const base32 = new Base32Encoding('abcdefghijklmnopqrstuvwxyz234567'); + +export function generateId(length = 15): string { + return generateRandomString(length, 'abcdefghijklmnopqrstuvwxyz0123456789'); +} + +export function generateSessionToken(): string { + const bytes = new Uint8Array(20); + crypto.getRandomValues(bytes); + const token = base32.encode(bytes, { + includePadding: false, + }); + return token; +} + +export async function createSession( + token: string, + userId: string, +): Promise { + const sessionId = encodeHex(await sha256(new TextEncoder().encode(token))); + const session: Session = { + id: sessionId, + userId, + expiresAt: new Date(Date.now() + ONE_DAY * 7), + }; + await db + .insertInto('Session') + .values({ + id: session.id, + user_id: session.userId, + expires_at: Math.floor(session.expiresAt.getTime() / 1000), + }) + .execute(); + return session; +} + +export async function validateSessionToken( + token: string, +): Promise { + const sessionId = encodeHex(await sha256(new TextEncoder().encode(token))); + const row = await db + .selectFrom('Session as s') + .innerJoin('User as u', 'u.id', 's.user_id') + .select(['s.id', 's.user_id', 's.expires_at', 'u.twitch_id', 'u.username']) + .where('s.id', '=', sessionId) + .executeTakeFirst(); + if (!row) { + return { session: null, user: null }; + } + const session: Session = { + id: row.id, + userId: row.user_id, + expiresAt: new Date(row.expires_at * 1000), + }; + if (Date.now() >= session.expiresAt.getTime()) { + await db.deleteFrom('Session').where('id', '=', session.id).execute(); + return { session: null, user: null }; + } + const user: User = { + id: row.user_id, + twitch_id: row.twitch_id, + username: row.username, + }; + if (Date.now() >= session.expiresAt.getTime() - ONE_DAY * 15) { + session.expiresAt = new Date(Date.now() + ONE_DAY * 30); + await db + .updateTable('Session') + .set({ + expires_at: Math.floor(session.expiresAt.getTime() / 1000), + }) + .where('id', '=', session.id) + .execute(); + } + return { session, user }; +} + +export async function invalidateSession(sessionId: string): Promise { + await db.deleteFrom('Session').where('id', '=', sessionId).execute(); +} + +export type SessionValidationResult = + | { session: Session; user: User } + | { session: null; user: null }; + +export interface Session { + id: string; + userId: string; + expiresAt: Date; +} + +export type User = Selectable; + +export let twitch: Twitch; +export function initAuth(origin: string) { + if (twitch) return; + twitch = new Twitch(CLIENT_ID, CLIENT_SECRET, origin + '/api/auth/callback'); +} diff --git a/template_builder/templates/extras/src/lib/components/{Svelte5}NextStep.svelte b/template_builder/templates/extras/src/lib/components/{Svelte5}NextStep.svelte deleted file mode 100644 index a788b3e4..00000000 --- a/template_builder/templates/extras/src/lib/components/{Svelte5}NextStep.svelte +++ /dev/null @@ -1,26 +0,0 @@ - - -
-

{title}

- {@render children()} -
- Learn more - -
diff --git a/template_builder/templates/extras/src/lib/server/{Auth,D1}auth.ts b/template_builder/templates/extras/src/lib/server/{Auth,D1}auth.ts deleted file mode 100644 index 49ff4155..00000000 --- a/template_builder/templates/extras/src/lib/server/{Auth,D1}auth.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { Selectable } from 'kysely'; -import { Lucia } from 'lucia'; -import { D1Adapter } from '@lucia-auth/adapter-sqlite'; -import { dev } from '$app/environment'; -import type { DB } from '$lib/db/schema'; -import { Twitch } from 'arctic'; -import { CLIENT_ID, CLIENT_SECRET } from '$env/static/private'; - -export let lucia: NonNullable>; -export let twitch: Twitch; - -export function initLucia(db: D1Database, origin: string) { - if (lucia) return; - const adapter = new D1Adapter(db, { - user: 'User', - session: 'Session', - }); - const l = new Lucia(adapter, { - sessionCookie: { - attributes: { - secure: !dev, - }, - }, - getUserAttributes(db) { - return { - twitchId: db.twitch_id, - username: db.username, - }; - }, - }); - lucia = l; - twitch = new Twitch(CLIENT_ID, CLIENT_SECRET, origin + '/api/auth/callback'); - return l; -} - -declare module 'lucia' { - interface Register { - Lucia: typeof lucia; - DatabaseUserAttributes: Selectable; - } -} diff --git a/template_builder/templates/extras/src/lib/server/{Auth,Planetscale}auth.ts b/template_builder/templates/extras/src/lib/server/{Auth,Planetscale}auth.ts deleted file mode 100644 index 11331faa..00000000 --- a/template_builder/templates/extras/src/lib/server/{Auth,Planetscale}auth.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { Selectable } from 'kysely'; -import { Lucia } from 'lucia'; -import { PlanetScaleAdapter } from '@lucia-auth/adapter-mysql'; -import { dev } from '$app/environment'; -import type { DB } from '$lib/db/schema'; -import { Twitch } from 'arctic'; -import { CLIENT_ID, CLIENT_SECRET } from '$env/static/private'; -import { connect, cast } from '@planetscale/database'; -import { - DATABASE_HOST, - DATABASE_USERNAME, - DATABASE_PASSWORD, -} from '$env/static/private'; - -const adapter = new PlanetScaleAdapter( - connect({ - host: DATABASE_HOST, - username: DATABASE_USERNAME, - password: DATABASE_PASSWORD, - cast: (field, value) => { - if (field.type === 'INT8' && value === '1') return true; - if (field.type === 'INT8' && value === '0') return false; - return cast(field, value); - }, - }), - { - user: 'User', - session: 'Session', - }, -); - -export const lucia = new Lucia(adapter, { - sessionCookie: { - attributes: { - secure: !dev, - }, - }, - getUserAttributes(db) { - return { - twitchId: db.twitch_id, - username: db.username, - }; - }, -}); -export let twitch: Twitch; - -export function initLucia(origin: string) { - if (twitch) return; - twitch = new Twitch(CLIENT_ID, CLIENT_SECRET, origin + '/api/auth/callback'); -} - -declare module 'lucia' { - interface Register { - Lucia: typeof lucia; - DatabaseUserAttributes: Selectable; - } -} diff --git a/template_builder/templates/extras/src/lib/server/{Auth,Sqlite}auth.ts b/template_builder/templates/extras/src/lib/server/{Auth,Sqlite}auth.ts deleted file mode 100644 index 1297711b..00000000 --- a/template_builder/templates/extras/src/lib/server/{Auth,Sqlite}auth.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { Selectable } from 'kysely'; -import { Lucia } from 'lucia'; -import { BetterSqlite3Adapter } from '@lucia-auth/adapter-sqlite'; -import { dev } from '$app/environment'; -import type { DB } from '$lib/db/schema'; -import { Twitch } from 'arctic'; -import { CLIENT_ID, CLIENT_SECRET } from '$env/static/private'; -import { sqlite } from '$lib/db'; - -const adapter = new BetterSqlite3Adapter(sqlite, { - user: 'User', - session: 'Session', -}); - -export const lucia = new Lucia(adapter, { - sessionCookie: { - attributes: { - secure: !dev, - }, - }, - getUserAttributes(db) { - return { - twitchId: db.twitch_id, - username: db.username, - }; - }, -}); -export let twitch: Twitch; - -export function initLucia(origin: string) { - if (twitch) return; - twitch = new Twitch(CLIENT_ID, CLIENT_SECRET, origin + '/api/auth/callback'); -} - -declare module 'lucia' { - interface Register { - Lucia: typeof lucia; - DatabaseUserAttributes: Selectable; - } -} diff --git a/template_builder/templates/extras/src/lib/server/{Auth,Turso}auth.ts b/template_builder/templates/extras/src/lib/server/{Auth,Turso}auth.ts deleted file mode 100644 index 5fd960eb..00000000 --- a/template_builder/templates/extras/src/lib/server/{Auth,Turso}auth.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { Selectable } from 'kysely'; -import { Lucia } from 'lucia'; -import { LibSQLAdapter } from '@lucia-auth/adapter-sqlite'; -import { dev } from '$app/environment'; -import type { DB } from '$lib/db/schema'; -import { Twitch } from 'arctic'; -import { CLIENT_ID, CLIENT_SECRET } from '$env/static/private'; -import { dbClient } from '$lib/db'; - -const adapter = new LibSQLAdapter(dbClient, { - user: 'User', - session: 'Session', -}); - -export const lucia = new Lucia(adapter, { - sessionCookie: { - attributes: { - secure: !dev, - }, - }, - getUserAttributes(db) { - return { - twitchId: db.twitch_id, - username: db.username, - }; - }, -}); -export let twitch: Twitch; - -export function initLucia(origin: string) { - if (twitch) return; - twitch = new Twitch(CLIENT_ID, CLIENT_SECRET, origin + '/api/auth/callback'); -} - -declare module 'lucia' { - interface Register { - Lucia: typeof lucia; - DatabaseUserAttributes: Selectable; - } -} diff --git a/template_builder/templates/extras/src/lib/server/{Trpc,Auth}trpc.ts b/template_builder/templates/extras/src/lib/server/{Trpc,Auth}trpc.ts index e3c2e081..7f6384c7 100644 --- a/template_builder/templates/extras/src/lib/server/{Trpc,Auth}trpc.ts +++ b/template_builder/templates/extras/src/lib/server/{Trpc,Auth}trpc.ts @@ -1,6 +1,6 @@ import { TRPCError, initTRPC } from '@trpc/server'; import type { Context } from './context'; -import { transformer } from '$lib/trpc/transformer'; +import { transformer } from '$lib/trpc'; const t = initTRPC.context().create({ transformer, diff --git a/template_builder/templates/extras/src/lib/server/{Trpc}trpc.ts b/template_builder/templates/extras/src/lib/server/{Trpc}trpc.ts index a3d00625..4307515f 100644 --- a/template_builder/templates/extras/src/lib/server/{Trpc}trpc.ts +++ b/template_builder/templates/extras/src/lib/server/{Trpc}trpc.ts @@ -1,6 +1,6 @@ import { initTRPC } from '@trpc/server'; import type { Context } from './context'; -import { transformer } from '$lib/trpc/transformer'; +import { transformer } from '$lib/trpc'; const t = initTRPC.context().create({ transformer, diff --git a/template_builder/templates/extras/src/lib/trpc/{Trpc}index.ts b/template_builder/templates/extras/src/lib/trpc/{Trpc}index.ts deleted file mode 100644 index 7b24c96d..00000000 --- a/template_builder/templates/extras/src/lib/trpc/{Trpc}index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createTRPCSvelte } from 'trpc-svelte-query'; -import { httpBatchLink } from '@trpc/client'; -import type { AppRouter } from '$lib/server/routes/_app'; -import { transformer } from './transformer'; - -export const trpc = createTRPCSvelte({ - links: [ - httpBatchLink({ - url: '/api/trpc', - }), - ], - transformer, -}); diff --git a/template_builder/templates/extras/src/lib/trpc/{Trpc}transformer.ts b/template_builder/templates/extras/src/lib/{Trpc}trpc.ts similarity index 53% rename from template_builder/templates/extras/src/lib/trpc/{Trpc}transformer.ts rename to template_builder/templates/extras/src/lib/{Trpc}trpc.ts index ecb3177b..2c33ea09 100644 --- a/template_builder/templates/extras/src/lib/trpc/{Trpc}transformer.ts +++ b/template_builder/templates/extras/src/lib/{Trpc}trpc.ts @@ -1,3 +1,6 @@ +import { createTRPCSvelte } from 'trpc-svelte-query'; +import { httpBatchLink } from '@trpc/client'; +import type { AppRouter } from '$lib/server/routes/_app'; import { parse, stringify, uneval } from 'devalue'; export const transformer = { @@ -10,3 +13,12 @@ export const transformer = { deserialize: (object: string) => (0, eval)(`(${object})`), }, }; + +export const trpc = createTRPCSvelte({ + links: [ + httpBatchLink({ + url: '/api/trpc', + }), + ], + transformer, +}); diff --git a/template_builder/templates/extras/src/routes/api/auth/callback/{Auth}+server.ts b/template_builder/templates/extras/src/routes/api/auth/callback/{Auth}+server.ts index 18c86ecd..507d297b 100644 --- a/template_builder/templates/extras/src/routes/api/auth/callback/{Auth}+server.ts +++ b/template_builder/templates/extras/src/routes/api/auth/callback/{Auth}+server.ts @@ -1,8 +1,14 @@ -import { OAuth2RequestError } from 'arctic'; -import { generateId } from 'lucia'; -import { twitch, lucia } from '$lib/server/auth'; +import { OAuth2Tokens } from 'arctic'; import { db } from '$lib/db'; import { CLIENT_ID } from '$env/static/private'; +import { error, redirect } from '@sveltejs/kit'; +import { + createSession, + generateId, + generateSessionToken, + twitch, +} from '$lib/auth'; +import { dev } from '$app/environment'; export const GET = async (event) => { const code = event.url.searchParams.get('code'); @@ -14,70 +20,55 @@ export const GET = async (event) => { status: 400, }); } - + let tokens: OAuth2Tokens; try { - const tokens = await twitch.validateAuthorizationCode(code); - const twitchUser = await fetch('https://api.twitch.tv/helix/users', { - headers: { - Authorization: `Bearer ${tokens.accessToken}`, - 'Client-ID': CLIENT_ID, - }, - }) - .then((r) => r.json() as Promise) - .then((u) => u.data[0]); - - // Replace this with your own DB client. - const existingUser = await db - .selectFrom('User') - .select('id') - .where('twitch_id', '=', twitchUser.id) - .executeTakeFirst(); + tokens = await twitch.validateAuthorizationCode(code); + } catch (err) { + console.error('Invalid code or client ID', err); + // Invalid code or client ID + return error(400, 'Authentication failed'); + } - if (existingUser) { - const session = await lucia.createSession(existingUser.id, {}); - const sessionCookie = lucia.createSessionCookie(session.id); - event.cookies.set(sessionCookie.name, sessionCookie.value, { - path: '.', - ...sessionCookie.attributes, - }); - } else { - const userId = generateId(15); + const twitchUser = await fetch('https://api.twitch.tv/helix/users', { + headers: { + Authorization: `Bearer ${tokens.accessToken()}`, + 'Client-ID': CLIENT_ID, + }, + }) + .then((r) => r.json() as Promise) + .then((u) => u.data[0]); - // Replace this with your own DB client. - await db - .insertInto('User') - .values({ - id: userId, - twitch_id: twitchUser.id, - username: twitchUser.display_name, - }) - .execute(); + let user = await db + .selectFrom('User') + .select('id') + .where('twitch_id', '=', twitchUser.id) + .executeTakeFirst(); - const session = await lucia.createSession(userId, {}); - const sessionCookie = lucia.createSessionCookie(session.id); - event.cookies.set(sessionCookie.name, sessionCookie.value, { - path: '.', - ...sessionCookie.attributes, - }); - } - return new Response(null, { - status: 302, - headers: { - Location: '/', - }, - }); - } catch (e) { - // the specific error message depends on the provider - if (e instanceof OAuth2RequestError) { - // invalid code - return new Response(null, { - status: 400, - }); - } - return new Response(null, { - status: 500, - }); + if (!user) { + user = { + id: generateId(15), + }; + await db + .insertInto('User') + .values({ + id: user.id, + twitch_id: twitchUser.id, + username: twitchUser.display_name, + }) + .execute(); } + + const sessionToken = generateSessionToken(); + const session = await createSession(sessionToken, user.id); + + event.cookies.set('session', sessionToken, { + path: '/', + httpOnly: true, + sameSite: 'lax', + expires: session.expiresAt, + secure: !dev, + }); + redirect(302, '/'); }; interface TwitchUser { diff --git a/template_builder/templates/extras/src/routes/api/auth/login/{Auth}+server.ts b/template_builder/templates/extras/src/routes/api/auth/login/{Auth}+server.ts index 0e8620c9..42258b5a 100644 --- a/template_builder/templates/extras/src/routes/api/auth/login/{Auth}+server.ts +++ b/template_builder/templates/extras/src/routes/api/auth/login/{Auth}+server.ts @@ -1,13 +1,11 @@ import { redirect } from '@sveltejs/kit'; import { generateState } from 'arctic'; -import { twitch } from '$lib/server/auth'; +import { twitch } from '$lib/auth'; import { dev } from '$app/environment'; export const GET = async (event) => { const state = generateState(); - const url = await twitch.createAuthorizationURL(state, { - scopes: [], - }); + const url = twitch.createAuthorizationURL(state, []); event.cookies.set('oauth_state', state, { path: '/', diff --git a/template_builder/templates/extras/src/routes/api/auth/logout/{Auth}+server.ts b/template_builder/templates/extras/src/routes/api/auth/logout/{Auth}+server.ts index 43cf3199..c0d8e9aa 100644 --- a/template_builder/templates/extras/src/routes/api/auth/logout/{Auth}+server.ts +++ b/template_builder/templates/extras/src/routes/api/auth/logout/{Auth}+server.ts @@ -1,7 +1,7 @@ -import { lucia } from '$lib/server/auth'; +import { invalidateSession } from '$lib/auth'; import { redirect } from '@sveltejs/kit'; export const GET = async ({ locals }) => { - if (locals.session) await lucia.invalidateSession(locals.session.id); + if (locals.session) await invalidateSession(locals.session.id); redirect(302, '/'); }; diff --git a/template_builder/templates/extras/src/routes/{Svelte5}+layout.svelte b/template_builder/templates/extras/src/routes/{Svelte5}+layout.svelte deleted file mode 100644 index d6d6d225..00000000 --- a/template_builder/templates/extras/src/routes/{Svelte5}+layout.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - -{@render children()} diff --git a/template_builder/templates/extras/src/routes/{Trpc,Svelte5}+layout.svelte b/template_builder/templates/extras/src/routes/{Trpc,Svelte5}+layout.svelte deleted file mode 100644 index 2419e241..00000000 --- a/template_builder/templates/extras/src/routes/{Trpc,Svelte5}+layout.svelte +++ /dev/null @@ -1,13 +0,0 @@ - - - - {@render children()} - diff --git a/template_builder/templates/extras/src/routes/{Trpc}+layout.svelte b/template_builder/templates/extras/src/routes/{Trpc}+layout.svelte index 81379056..2419e241 100644 --- a/template_builder/templates/extras/src/routes/{Trpc}+layout.svelte +++ b/template_builder/templates/extras/src/routes/{Trpc}+layout.svelte @@ -1,14 +1,13 @@ - + {@render children()} diff --git a/template_builder/templates/extras/src/{Auth,D1}hooks.server.ts b/template_builder/templates/extras/src/{Auth,D1}hooks.server.ts index b8d2aa2b..685cf876 100644 --- a/template_builder/templates/extras/src/{Auth,D1}hooks.server.ts +++ b/template_builder/templates/extras/src/{Auth,D1}hooks.server.ts @@ -1,32 +1,33 @@ import { initDb } from '$lib/db'; -import { initLucia, lucia } from '$lib/server/auth'; -import type { Cookie } from 'lucia'; +import { initAuth, validateSessionToken } from '$lib/auth'; +import { dev } from '$app/environment'; export async function handle({ event, resolve }) { const db = event.platform!.env.DB; - initLucia(db, event.url.origin); + initAuth(event.url.origin); initDb(db); - const sessionId = event.cookies.get(lucia.sessionCookieName); - if (!sessionId) { + const sessionToken = event.cookies.get('session'); + if (!sessionToken) { event.locals.user = null; event.locals.session = null; return resolve(event); } - const { session, user } = await lucia.validateSession(sessionId); - let sessionCookie: Cookie | undefined; - if (session && session.fresh) { - sessionCookie = lucia.createSessionCookie(session.id); - } - if (!session) { - sessionCookie = lucia.createBlankSessionCookie(); - } - if (sessionCookie) { - event.cookies.set(sessionCookie.name, sessionCookie.value, { - path: '.', - ...sessionCookie.attributes, + const { session, user } = await validateSessionToken(sessionToken); + if (session) { + event.cookies.set('session', sessionToken, { + path: '/', + httpOnly: true, + sameSite: 'lax', + expires: session.expiresAt, + secure: !dev, + }); + } else { + event.cookies.delete('session', { + path: '/', }); } + event.locals.user = user; event.locals.session = session; return resolve(event); diff --git a/template_builder/templates/extras/src/{Auth,Sqlite|Planetscale|Turso}hooks.server.ts b/template_builder/templates/extras/src/{Auth,Sqlite|Planetscale|Turso}hooks.server.ts index 31b8222d..551bfba1 100644 --- a/template_builder/templates/extras/src/{Auth,Sqlite|Planetscale|Turso}hooks.server.ts +++ b/template_builder/templates/extras/src/{Auth,Sqlite|Planetscale|Turso}hooks.server.ts @@ -1,29 +1,30 @@ -import { initLucia, lucia } from '$lib/server/auth'; -import type { Cookie } from 'lucia'; +import { initAuth, validateSessionToken } from '$lib/auth'; +import { dev } from '$app/environment'; export async function handle({ event, resolve }) { - initLucia(event.url.origin); - const sessionId = event.cookies.get(lucia.sessionCookieName); - if (!sessionId) { + initAuth(event.url.origin); + const sessionToken = event.cookies.get('session'); + if (!sessionToken) { event.locals.user = null; event.locals.session = null; return resolve(event); } - const { session, user } = await lucia.validateSession(sessionId); - let sessionCookie: Cookie | undefined; - if (session && session.fresh) { - sessionCookie = lucia.createSessionCookie(session.id); - } - if (!session) { - sessionCookie = lucia.createBlankSessionCookie(); - } - if (sessionCookie) { - event.cookies.set(sessionCookie.name, sessionCookie.value, { - path: '.', - ...sessionCookie.attributes, + const { session, user } = await validateSessionToken(sessionToken); + if (session) { + event.cookies.set('session', sessionToken, { + path: '/', + httpOnly: true, + sameSite: 'lax', + expires: session.expiresAt, + secure: !dev, + }); + } else { + event.cookies.delete('session', { + path: '/', }); } + event.locals.user = user; event.locals.session = session; return resolve(event); diff --git a/template_builder/templates/extras/src/{Auth}app.d.ts b/template_builder/templates/extras/src/{Auth}app.d.ts index b2f30b1f..b15719db 100644 --- a/template_builder/templates/extras/src/{Auth}app.d.ts +++ b/template_builder/templates/extras/src/{Auth}app.d.ts @@ -2,8 +2,8 @@ declare global { namespace App { // interface Platform {} interface Locals { - user: import('lucia').User | null; - session: import('lucia').Session | null; + user: import('$lib/auth').User | null; + session: import('$lib/auth').Session | null; } // interface Error {} // interface Session {} diff --git a/template_builder/templates/extras/src/{Edge,Auth,D1}app.d.ts b/template_builder/templates/extras/src/{Edge,Auth,D1}app.d.ts index cda2b05d..0dfe6b24 100644 --- a/template_builder/templates/extras/src/{Edge,Auth,D1}app.d.ts +++ b/template_builder/templates/extras/src/{Edge,Auth,D1}app.d.ts @@ -10,8 +10,8 @@ declare global { } interface Locals { - user: import('lucia').User | null; - session: import('lucia').Session | null; + user: import('$lib/auth').User | null; + session: import('$lib/auth').Session | null; } // interface Error {} // interface Session {} diff --git a/template_builder/templates/extras/src/{Edge,Auth}app.d.ts b/template_builder/templates/extras/src/{Edge,Auth}app.d.ts index 7ef7a460..07d29b52 100644 --- a/template_builder/templates/extras/src/{Edge,Auth}app.d.ts +++ b/template_builder/templates/extras/src/{Edge,Auth}app.d.ts @@ -11,8 +11,8 @@ declare global { } interface Locals { - user: import('lucia').User | null; - session: import('lucia').Session | null; + user: import('$lib/auth').User | null; + session: import('$lib/auth').Session | null; } // interface Error {} // interface Session {} diff --git a/template_builder/templates/extras/worker/{Sidecar,Npm}package.json b/template_builder/templates/extras/worker/{Sidecar,Npm}package.json index bd969056..492ec34a 100644 --- a/template_builder/templates/extras/worker/{Sidecar,Npm}package.json +++ b/template_builder/templates/extras/worker/{Sidecar,Npm}package.json @@ -8,11 +8,11 @@ }, "dependencies": { "common": "^0.0.0", - "hono": "^4.6.3" + "hono": "^4.6.5" }, "devDependencies": { - "@cloudflare/workers-types": "^4.20241004.0", + "@cloudflare/workers-types": "^4.20241018.0", "typescript": "^5.6.3", - "wrangler": "^3.80.3" + "wrangler": "^3.81.0" } } diff --git a/template_builder/templates/extras/worker/{Sidecar}package.json b/template_builder/templates/extras/worker/{Sidecar}package.json index 53be8b4c..9e2d6d8d 100644 --- a/template_builder/templates/extras/worker/{Sidecar}package.json +++ b/template_builder/templates/extras/worker/{Sidecar}package.json @@ -9,11 +9,11 @@ }, "dependencies": { "common": "workspace:*", - "hono": "^4.6.3" + "hono": "^4.6.5" }, "devDependencies": { - "@cloudflare/workers-types": "^4.20241004.0", + "@cloudflare/workers-types": "^4.20241018.0", "typescript": "^5.6.3", - "wrangler": "^3.80.3" + "wrangler": "^3.81.0" } } diff --git a/template_builder/templates/extras/worker/{Sidecar}wrangler.toml b/template_builder/templates/extras/worker/{Sidecar}wrangler.toml index 58c3455a..f1fd2380 100644 --- a/template_builder/templates/extras/worker/{Sidecar}wrangler.toml +++ b/template_builder/templates/extras/worker/{Sidecar}wrangler.toml @@ -1,7 +1,7 @@ #:schema node_modules/wrangler/config-schema.json name = "__o7__name__-worker" main = "src/worker.ts" -compatibility_date = "2024-07-01" +compatibility_date = "2024-09-02" [[durable_objects.bindings]] name = "SOCKET_OBJECT" @@ -9,4 +9,4 @@ class_name = "SocketObject" [[migrations]] tag = "v1" -new_classes = ["SocketObject"] +new_sqlite_classes = ["SocketObject"] diff --git a/template_builder/templates/extras/{Auth,D1|Sqlite|Turso}package.json b/template_builder/templates/extras/{Auth,D1|Sqlite|Turso}package.json deleted file mode 100644 index 6b2237cd..00000000 --- a/template_builder/templates/extras/{Auth,D1|Sqlite|Turso}package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "devDependencies": { - "@lucia-auth/adapter-sqlite": "^3.0.2" - } -} diff --git a/template_builder/templates/extras/{Auth,Planetscale}package.json b/template_builder/templates/extras/{Auth,Planetscale}package.json deleted file mode 100644 index 23ae2f13..00000000 --- a/template_builder/templates/extras/{Auth,Planetscale}package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "devDependencies": { - "@lucia-auth/adapter-mysql": "^3.0.2" - } -} diff --git a/template_builder/templates/extras/{Auth}package.json b/template_builder/templates/extras/{Auth}package.json index 1657727c..b4101245 100644 --- a/template_builder/templates/extras/{Auth}package.json +++ b/template_builder/templates/extras/{Auth}package.json @@ -1,9 +1,6 @@ { "dependencies": { - "arctic": "^1.9.2", + "arctic": "^2.0.1", "oslo": "^1.2.1" - }, - "devDependencies": { - "lucia": "^3.2.1" } } diff --git a/template_builder/templates/extras/{D1|Planetscale|Sqlite|Turso}package.json b/template_builder/templates/extras/{D1|Planetscale|Sqlite|Turso}package.json index 7d9deaa1..a799a819 100644 --- a/template_builder/templates/extras/{D1|Planetscale|Sqlite|Turso}package.json +++ b/template_builder/templates/extras/{D1|Planetscale|Sqlite|Turso}package.json @@ -4,6 +4,6 @@ }, "devDependencies": { "prisma-kysely": "^1.8.0", - "prisma": "^5.20.0" + "prisma": "^5.21.1" } } diff --git a/template_builder/templates/extras/{D1}package.json b/template_builder/templates/extras/{D1}package.json index 2841ee5b..b297d571 100644 --- a/template_builder/templates/extras/{D1}package.json +++ b/template_builder/templates/extras/{D1}package.json @@ -8,7 +8,7 @@ }, "devDependencies": { "dotenv": "^16.4.5", - "better-sqlite3": "^11.3.0", + "better-sqlite3": "^11.4.0", "@types/better-sqlite3": "^7.6.11" } } diff --git a/template_builder/templates/extras/{Edge,D1}wrangler.toml b/template_builder/templates/extras/{Edge,D1}wrangler.toml index fe7c6526..f8a4ebf9 100644 --- a/template_builder/templates/extras/{Edge,D1}wrangler.toml +++ b/template_builder/templates/extras/{Edge,D1}wrangler.toml @@ -1,6 +1,6 @@ name = "__o7__name__" pages_build_output_dir = "./.svelte-kit/cloudflare" -compatibility_date = "2024-07-01" +compatibility_date = "2024-09-02" # Run `pnpm wrangler d1 create ` before deploying! [[d1_databases]] diff --git a/template_builder/templates/extras/{Edge}package.json b/template_builder/templates/extras/{Edge}package.json index 954b8d61..5766e09c 100644 --- a/template_builder/templates/extras/{Edge}package.json +++ b/template_builder/templates/extras/{Edge}package.json @@ -1,8 +1,8 @@ { "devDependencies": { - "@cloudflare/workers-types": "^4.20241004.0", - "@sveltejs/adapter-cloudflare": "^4.7.2", - "wrangler": "^3.80.3", + "@cloudflare/workers-types": "^4.20241018.0", + "@sveltejs/adapter-cloudflare": "^4.7.3", + "wrangler": "^3.81.0", "@sveltejs/adapter-auto": null } } diff --git a/template_builder/templates/extras/{Edge}wrangler.toml b/template_builder/templates/extras/{Edge}wrangler.toml index 6dd119e5..837cc81e 100644 --- a/template_builder/templates/extras/{Edge}wrangler.toml +++ b/template_builder/templates/extras/{Edge}wrangler.toml @@ -1,6 +1,6 @@ name = "__o7__name__" pages_build_output_dir = "./.svelte-kit/cloudflare" -compatibility_date = "2024-07-01" +compatibility_date = "2024-09-02" # [[kv_namespaces]] # binding = "KV" diff --git a/template_builder/templates/extras/{Sqlite}package.json b/template_builder/templates/extras/{Sqlite}package.json index 9014ff44..35bea4a6 100644 --- a/template_builder/templates/extras/{Sqlite}package.json +++ b/template_builder/templates/extras/{Sqlite}package.json @@ -3,7 +3,7 @@ "db:push": "prisma db push" }, "dependencies": { - "better-sqlite3": "^11.3.0" + "better-sqlite3": "^11.4.0" }, "devDependencies": { "@types/better-sqlite3": "^7.6.11" diff --git a/template_builder/templates/extras/{Svelte5}package.json b/template_builder/templates/extras/{Svelte5}package.json deleted file mode 100644 index 0c934e4f..00000000 --- a/template_builder/templates/extras/{Svelte5}package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "devDependencies": { - "svelte": "^5.0.0-next.264", - "eslint-plugin-svelte": "^2.36.0-next.13", - "@sveltejs/vite-plugin-svelte": "^4.0.0-next.8" - } -} diff --git a/template_builder/templates/extras/{Trpc}package.json b/template_builder/templates/extras/{Trpc}package.json index fb1495cc..59f7ebc2 100644 --- a/template_builder/templates/extras/{Trpc}package.json +++ b/template_builder/templates/extras/{Trpc}package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@tanstack/svelte-query": "^5.59.9", + "@tanstack/svelte-query": "^5.59.13", "@trpc/client": "^10.45.2", "@trpc/server": "^10.45.2", "devalue": "^5.1.1", diff --git a/template_builder/templates/extras/{Turso}package.json b/template_builder/templates/extras/{Turso}package.json index 6683e1f2..2e1f4881 100644 --- a/template_builder/templates/extras/{Turso}package.json +++ b/template_builder/templates/extras/{Turso}package.json @@ -8,7 +8,7 @@ }, "devDependencies": { "dotenv": "^16.4.5", - "better-sqlite3": "^11.3.0", + "better-sqlite3": "^11.4.0", "@types/better-sqlite3": "^7.6.11" } }