diff --git a/package.json b/package.json index a4c3e143..23f7d3b2 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "ofetch": "^1.3.4", "ohash": "^1.1.3", "pathe": "^1.1.2", + "scule": "^1.3.0", "uncrypto": "^0.1.3" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 651a32a3..6fd0301b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ importers: pathe: specifier: ^1.1.2 version: 1.1.2 + scule: + specifier: ^1.3.0 + version: 1.3.0 uncrypto: specifier: ^0.1.3 version: 0.1.3 @@ -35,7 +38,7 @@ importers: version: 1.1.113 '@nuxt/devtools': specifier: latest - version: 1.3.9(rollup@3.29.4) + version: 1.3.14(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) '@nuxt/eslint-config': specifier: ^0.5.0 version: 0.5.0(eslint@9.9.0(jiti@1.21.6))(typescript@5.5.4) @@ -47,13 +50,13 @@ importers: version: 3.12.4(rollup@3.29.4) '@nuxt/test-utils': specifier: ^3.14.0 - version: 3.14.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4)) + version: 3.14.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4)) '@nuxt/ui': specifier: ^2.18.4 - version: 2.18.4(magicast@0.3.4)(rollup@3.29.4)(vue@3.4.34(typescript@5.5.4)) + version: 2.18.4(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4)) '@nuxt/ui-pro': specifier: ^1.4.1 - version: 1.4.1(magicast@0.3.4)(rollup@3.29.4)(vue@3.4.34(typescript@5.5.4)) + version: 1.4.1(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4)) changelogen: specifier: ^0.5.5 version: 0.5.5(magicast@0.3.4) @@ -62,7 +65,7 @@ importers: version: 9.9.0(jiti@1.21.6) nuxt: specifier: ^3.12.4 - version: 3.12.4(@parcel/watcher@2.4.1)(@types/node@22.2.0)(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@3.29.4)(terser@5.31.3)(typescript@5.5.4)(vue-tsc@2.0.29(typescript@5.5.4)) + version: 3.12.4(@parcel/watcher@2.4.1)(@types/node@22.2.0)(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@3.29.4)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)) typescript: specifier: ^5.5.4 version: 5.5.4 @@ -80,7 +83,7 @@ importers: version: 3.12.4(@parcel/watcher@2.4.1)(@types/node@22.2.0)(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.1)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)) nuxt-auth-utils: specifier: latest - version: 0.3.2(magicast@0.3.4)(rollup@4.19.1) + version: 0.3.4(magicast@0.3.4)(rollup@4.19.1) devDependencies: '@iconify-json/gravity-ui': specifier: ^1.1.4 @@ -981,17 +984,22 @@ packages: '@nuxt/devalue@2.0.2': resolution: {integrity: sha512-GBzP8zOc7CGWyFQS6dv1lQz8VVpz5C2yRszbXufwG/9zhStTIH50EtD87NmWbTMwXDvZLNg8GIpb1UFdH93JCA==} + '@nuxt/devtools-kit@1.3.14': + resolution: {integrity: sha512-mLPuCf5nFYLm/1JD0twt8qfFGwoVhTRA4Zx9CPiyWCQNf7XJXb3TfhCm89vHpcPP+9T6ulZxRJp+JZETjXY8+A==} + peerDependencies: + vite: '*' + '@nuxt/devtools-kit@1.3.9': resolution: {integrity: sha512-tgr/F+4BbI53/JxgaXl3cuV9dMuCXMsd4GEXN+JqtCdAkDbH3wL79GGWx0/6I9acGzRsB6UZ1H6U96nfgcIrAw==} peerDependencies: vite: '*' - '@nuxt/devtools-wizard@1.3.9': - resolution: {integrity: sha512-WMgwWWuyng+Y6k7sfBI95wYnec8TPFkuYbHHOlYQgqE9dAewPisSbEm3WkB7p/W9UqxpN8mvKN5qUg4sTmEpgQ==} + '@nuxt/devtools-wizard@1.3.14': + resolution: {integrity: sha512-5kLB53/7YUME6Y8byrOxRhl0hXWm05jPStJd1CJHKDcGrp+hjxYZaSgEwYtEIQ0A1GF04rfL4bJ+qIL+7e0+9Q==} hasBin: true - '@nuxt/devtools@1.3.9': - resolution: {integrity: sha512-tFKlbUPgSXw4tyD8xpztQtJeVn3egdKbFCV0xc92FbfGbclAyaa3XhKA2tMWXEGZQpykAWMRNrGWN24FtXFA6Q==} + '@nuxt/devtools@1.3.14': + resolution: {integrity: sha512-ebeVWBisXbhJ7begAZTgSDF8cPbExHv4RPDb9fWTMI1YoVVxX+elqUPw0K6T5Yi4atdGhyxRtGMqjikl7QKp9w==} hasBin: true peerDependencies: vite: '*' @@ -2574,8 +2582,8 @@ packages: fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} - fast-npm-meta@0.1.1: - resolution: {integrity: sha512-uS9DjGncI/9XZ6HJFrci0WzSi++N8Jskbb2uB7+9SQlrgA3VaLhXhV9Gl5HwIGESHkayYYZFGnVNhJwRDKCWIA==} + fast-npm-meta@0.2.2: + resolution: {integrity: sha512-E+fdxeaOQGo/CMWc9f4uHFfgUPJRAu7N3uB8GBvB3SDPAIWJK4GKyYhkAGFq+GYrcbKNfQIz5VVQyJnDuPPCrg==} fastq@1.17.1: resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} @@ -3079,8 +3087,8 @@ packages: kolorist@1.8.0: resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} - launch-editor@2.8.0: - resolution: {integrity: sha512-vJranOAJrI/llyWGRQqiDM+adrw+k83fvmmx3+nV47g3+36xM15jE+zyZ6Ffel02+xSvuM0b2GDRosXZkbb6wA==} + launch-editor@2.8.1: + resolution: {integrity: sha512-elBx2l/tp9z99X5H/qev8uyDywVh0VXAwEbjk8kJhnc5grOFkGh7aW6q55me9xnYbss261XtnUrysZ+XvGbhQA==} lazystream@1.0.1: resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==} @@ -3403,8 +3411,8 @@ packages: engines: {node: ^16.10.0 || >=18.0.0} hasBin: true - nuxt-auth-utils@0.3.2: - resolution: {integrity: sha512-A2gRelkEQxLoosIUw6TFFsMaq06XJ6dVdUYKRSKzxfMepBUq5v7GXiw+gZ9TVAXb0YjN9obmqJOBzf2qNI77yw==} + nuxt-auth-utils@0.3.4: + resolution: {integrity: sha512-0CNREFADCyZtyAusV3n27y1jnvt2KjrZI2boaMbKPDWiyI8AcV1jESG1aBFOxyViKsF4YnXRY8QN3EJKYvxMjA==} nuxt@3.12.4: resolution: {integrity: sha512-/ddvyc2kgYYIN2UEjP8QIz48O/W3L0lZm7wChIDbOCj0vF/yLLeZHBaTb3aNvS9Hwp269nfjrm8j/mVxQK4RhA==} @@ -3602,6 +3610,9 @@ packages: pkg-types@1.1.3: resolution: {integrity: sha512-+JrgthZG6m3ckicaOB74TwQ+tBWsFl3qVQg7mN8ulwSOElJ7gBhKzj2VkCPnZ4NlF6kEquYU+RIYNVAvzd54UA==} + pkg-types@1.2.0: + resolution: {integrity: sha512-+ifYuSSqOQ8CqP4MbZA5hDpb97n3E8SVWdJe+Wms9kj745lmd3b7EZJiqvmLwAlmRfjrI7Hi5z3kdBJ93lFNPA==} + pluralize@8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} @@ -4430,6 +4441,9 @@ packages: resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} engines: {node: '>=18'} + unimport@3.11.1: + resolution: {integrity: sha512-DuB1Uoq01LrrXTScxnwOoMSlTXxyKcULguFxbLrMDFcE/CO0ZWHpEiyhovN0mycPt7K6luAHe8laqvwvuoeUPg==} + unimport@3.9.1: resolution: {integrity: sha512-4gtacoNH6YPx2Aa5Xfyrf8pU2RdXjWUACb/eF7bH1AcZtqs+6ijbNB0M3BPENbtVjnCcg8tw9UJ1jQGbCzKA6g==} @@ -4449,6 +4463,10 @@ packages: resolution: {integrity: sha512-KeczzHl2sATPQUx1gzo+EnUkmN4VmGBYRRVOZSGvGITE9rGHRDGqft6ONceP3vgXcyJ2XjX5axG5jMWUwNCYLw==} engines: {node: '>=14.0.0'} + unplugin@1.12.2: + resolution: {integrity: sha512-bEqQxeC7rxtxPZ3M5V4Djcc4lQqKPgGe3mAWZvxcSmX5jhGxll19NliaRzQSQPrk4xJZSGniK3puLWpRuZN7VQ==} + engines: {node: '>=14.0.0'} + unstorage@1.10.2: resolution: {integrity: sha512-cULBcwDqrS8UhlIysUJs2Dk0Mmt8h7B0E6mtR+relW9nZvsf/u4SkAYyNliPiPW7XtFNb5u3IUMkxGxFTTRTgQ==} peerDependencies: @@ -4582,8 +4600,8 @@ packages: vue-tsc: optional: true - vite-plugin-inspect@0.8.5: - resolution: {integrity: sha512-JvTUqsP1JNDw0lMZ5Z/r5cSj81VK2B7884LO1DC3GMBhdcjcsAnJjdWq7bzQL01Xbh+v60d3lju3g+z7eAtNew==} + vite-plugin-inspect@0.8.7: + resolution: {integrity: sha512-/XXou3MVc13A5O9/2Nd6xczjrUwt7ZyI9h8pTnUMkr5SshLcb0PJUOVq2V+XVkdeU4njsqAtmK87THZuO2coGA==} engines: {node: '>=14'} peerDependencies: '@nuxt/kit': '*' @@ -5526,17 +5544,18 @@ snapshots: '@nuxt/devalue@2.0.2': {} - '@nuxt/devtools-kit@1.3.9(magicast@0.3.4)(rollup@3.29.4)': + '@nuxt/devtools-kit@1.3.14(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))': dependencies: '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@3.29.4) '@nuxt/schema': 3.12.4(rollup@3.29.4) execa: 7.2.0 + vite: 5.3.5(@types/node@22.2.0)(terser@5.31.3) transitivePeerDependencies: - magicast - rollup - supports-color - '@nuxt/devtools-kit@1.3.9(magicast@0.3.4)(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))': + '@nuxt/devtools-kit@1.3.14(magicast@0.3.4)(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))': dependencies: '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.1) '@nuxt/schema': 3.12.4(rollup@4.19.1) @@ -5547,7 +5566,18 @@ snapshots: - rollup - supports-color - '@nuxt/devtools-wizard@1.3.9': + '@nuxt/devtools-kit@1.3.9(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))': + dependencies: + '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@3.29.4) + '@nuxt/schema': 3.12.4(rollup@3.29.4) + execa: 7.2.0 + vite: 5.3.5(@types/node@22.2.0)(terser@5.31.3) + transitivePeerDependencies: + - magicast + - rollup + - supports-color + + '@nuxt/devtools-wizard@1.3.14': dependencies: consola: 3.2.3 diff: 5.2.0 @@ -5560,11 +5590,11 @@ snapshots: rc9: 2.1.2 semver: 7.6.3 - '@nuxt/devtools@1.3.9(rollup@3.29.4)': + '@nuxt/devtools@1.3.14(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))': dependencies: '@antfu/utils': 0.7.10 - '@nuxt/devtools-kit': 1.3.9(magicast@0.3.4)(rollup@3.29.4) - '@nuxt/devtools-wizard': 1.3.9 + '@nuxt/devtools-kit': 1.3.14(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) + '@nuxt/devtools-wizard': 1.3.14 '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@3.29.4) '@vue/devtools-core': 7.3.3(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) '@vue/devtools-kit': 7.3.3 @@ -5575,13 +5605,13 @@ snapshots: error-stack-parser-es: 0.1.5 execa: 7.2.0 fast-glob: 3.3.2 - fast-npm-meta: 0.1.1 + fast-npm-meta: 0.2.2 flatted: 3.3.1 get-port-please: 3.1.2 hookable: 5.5.3 image-meta: 0.2.1 is-installed-globally: 1.0.0 - launch-editor: 2.8.0 + launch-editor: 2.8.1 local-pkg: 0.5.0 magicast: 0.3.4 nypm: 0.3.9 @@ -5594,8 +5624,9 @@ snapshots: semver: 7.6.3 simple-git: 3.25.0 sirv: 2.0.4 - unimport: 3.9.1(rollup@3.29.4) - vite-plugin-inspect: 0.8.5(@nuxt/kit@3.12.4(magicast@0.3.4)(rollup@3.29.4))(rollup@3.29.4) + unimport: 3.11.1(rollup@3.29.4) + vite: 5.3.5(@types/node@22.2.0)(terser@5.31.3) + vite-plugin-inspect: 0.8.7(@nuxt/kit@3.12.4(magicast@0.3.4)(rollup@3.29.4))(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) vite-plugin-vue-inspector: 5.1.3(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) which: 3.0.1 ws: 8.18.0 @@ -5605,11 +5636,11 @@ snapshots: - supports-color - utf-8-validate - '@nuxt/devtools@1.3.9(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))': + '@nuxt/devtools@1.3.14(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))': dependencies: '@antfu/utils': 0.7.10 - '@nuxt/devtools-kit': 1.3.9(magicast@0.3.4)(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) - '@nuxt/devtools-wizard': 1.3.9 + '@nuxt/devtools-kit': 1.3.14(magicast@0.3.4)(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) + '@nuxt/devtools-wizard': 1.3.14 '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.1) '@vue/devtools-core': 7.3.3(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) '@vue/devtools-kit': 7.3.3 @@ -5620,13 +5651,13 @@ snapshots: error-stack-parser-es: 0.1.5 execa: 7.2.0 fast-glob: 3.3.2 - fast-npm-meta: 0.1.1 + fast-npm-meta: 0.2.2 flatted: 3.3.1 get-port-please: 3.1.2 hookable: 5.5.3 image-meta: 0.2.1 is-installed-globally: 1.0.0 - launch-editor: 2.8.0 + launch-editor: 2.8.1 local-pkg: 0.5.0 magicast: 0.3.4 nypm: 0.3.9 @@ -5639,9 +5670,9 @@ snapshots: semver: 7.6.3 simple-git: 3.25.0 sirv: 2.0.4 - unimport: 3.9.1(rollup@4.19.1) + unimport: 3.11.1(rollup@4.19.1) vite: 5.3.5(@types/node@22.2.0)(terser@5.31.3) - vite-plugin-inspect: 0.8.5(@nuxt/kit@3.12.4(magicast@0.3.4)(rollup@4.19.1))(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) + vite-plugin-inspect: 0.8.7(@nuxt/kit@3.12.4(magicast@0.3.4)(rollup@4.19.1))(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) vite-plugin-vue-inspector: 5.1.3(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) which: 3.0.1 ws: 8.18.0 @@ -5685,13 +5716,13 @@ snapshots: - supports-color - typescript - '@nuxt/icon@1.4.5(magicast@0.3.4)(rollup@3.29.4)(vue@3.4.34(typescript@5.5.4))': + '@nuxt/icon@1.4.5(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4))': dependencies: '@iconify/collections': 1.0.444 '@iconify/types': 2.0.0 '@iconify/utils': 2.1.29 '@iconify/vue': 4.1.3-beta.1(vue@3.4.34(typescript@5.5.4)) - '@nuxt/devtools-kit': 1.3.9(magicast@0.3.4)(rollup@3.29.4) + '@nuxt/devtools-kit': 1.3.9(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@3.29.4) consola: 3.2.3 fast-glob: 3.3.2 @@ -5862,7 +5893,7 @@ snapshots: - rollup - supports-color - '@nuxt/test-utils@3.14.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4))': + '@nuxt/test-utils@3.14.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4))': dependencies: '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@3.29.4) '@nuxt/schema': 3.12.4(rollup@3.29.4) @@ -5888,7 +5919,8 @@ snapshots: ufo: 1.5.4 unenv: 1.10.0 unplugin: 1.12.0 - vitest-environment-nuxt: 1.0.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4)) + vite: 5.3.5(@types/node@22.2.0)(terser@5.31.3) + vitest-environment-nuxt: 1.0.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4)) vue: 3.4.34(typescript@5.5.4) vue-router: 4.4.0(vue@3.4.34(typescript@5.5.4)) optionalDependencies: @@ -5898,10 +5930,10 @@ snapshots: - rollup - supports-color - '@nuxt/ui-pro@1.4.1(magicast@0.3.4)(rollup@3.29.4)(vue@3.4.34(typescript@5.5.4))': + '@nuxt/ui-pro@1.4.1(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4))': dependencies: '@iconify-json/vscode-icons': 1.1.37 - '@nuxt/ui': 2.18.4(magicast@0.3.4)(rollup@3.29.4)(vue@3.4.34(typescript@5.5.4)) + '@nuxt/ui': 2.18.4(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4)) '@vueuse/core': 10.11.0(vue@3.4.34(typescript@5.5.4)) defu: 6.1.4 git-url-parse: 14.1.0 @@ -5932,12 +5964,12 @@ snapshots: - vite - vue - '@nuxt/ui@2.18.4(magicast@0.3.4)(rollup@3.29.4)(vue@3.4.34(typescript@5.5.4))': + '@nuxt/ui@2.18.4(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4))': dependencies: '@headlessui/tailwindcss': 0.2.1(tailwindcss@3.4.7) '@headlessui/vue': 1.7.22(vue@3.4.34(typescript@5.5.4)) '@iconify-json/heroicons': 1.1.23 - '@nuxt/icon': 1.4.5(magicast@0.3.4)(rollup@3.29.4)(vue@3.4.34(typescript@5.5.4)) + '@nuxt/icon': 1.4.5(magicast@0.3.4)(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4)) '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@3.29.4) '@nuxtjs/color-mode': 3.4.2(magicast@0.3.4)(rollup@3.29.4) '@nuxtjs/tailwindcss': 6.12.1(magicast@0.3.4)(rollup@3.29.4) @@ -7879,7 +7911,7 @@ snapshots: fast-levenshtein@2.0.6: {} - fast-npm-meta@0.1.1: {} + fast-npm-meta@0.2.2: {} fastq@1.17.1: dependencies: @@ -8394,7 +8426,7 @@ snapshots: kolorist@1.8.0: {} - launch-editor@2.8.0: + launch-editor@2.8.1: dependencies: picocolors: 1.0.1 shell-quote: 1.8.1 @@ -8769,7 +8801,7 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - nuxt-auth-utils@0.3.2(magicast@0.3.4)(rollup@4.19.1): + nuxt-auth-utils@0.3.4(magicast@0.3.4)(rollup@4.19.1): dependencies: '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.1) defu: 6.1.4 @@ -8783,10 +8815,10 @@ snapshots: - rollup - supports-color - nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.2.0)(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@3.29.4)(terser@5.31.3)(typescript@5.5.4)(vue-tsc@2.0.29(typescript@5.5.4)): + nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.2.0)(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@3.29.4)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)): dependencies: '@nuxt/devalue': 2.0.2 - '@nuxt/devtools': 1.3.9(rollup@3.29.4) + '@nuxt/devtools': 1.3.14(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@3.29.4) '@nuxt/schema': 3.12.4(rollup@3.29.4) '@nuxt/telemetry': 2.5.4(magicast@0.3.4)(rollup@3.29.4) @@ -8892,7 +8924,7 @@ snapshots: nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.2.0)(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.1)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)): dependencies: '@nuxt/devalue': 2.0.2 - '@nuxt/devtools': 1.3.9(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) + '@nuxt/devtools': 1.3.14(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)) '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.1) '@nuxt/schema': 3.12.4(rollup@4.19.1) '@nuxt/telemetry': 2.5.4(magicast@0.3.4)(rollup@4.19.1) @@ -9175,6 +9207,12 @@ snapshots: mlly: 1.7.1 pathe: 1.1.2 + pkg-types@1.2.0: + dependencies: + confbox: 0.1.7 + mlly: 1.7.1 + pathe: 1.1.2 + pluralize@8.0.0: {} portfinder@1.0.32: @@ -10039,6 +10077,42 @@ snapshots: unicorn-magic@0.1.0: {} + unimport@3.11.1(rollup@3.29.4): + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@3.29.4) + acorn: 8.12.1 + escape-string-regexp: 5.0.0 + estree-walker: 3.0.3 + fast-glob: 3.3.2 + local-pkg: 0.5.0 + magic-string: 0.30.11 + mlly: 1.7.1 + pathe: 1.1.2 + pkg-types: 1.2.0 + scule: 1.3.0 + strip-literal: 2.1.0 + unplugin: 1.12.2 + transitivePeerDependencies: + - rollup + + unimport@3.11.1(rollup@4.19.1): + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@4.19.1) + acorn: 8.12.1 + escape-string-regexp: 5.0.0 + estree-walker: 3.0.3 + fast-glob: 3.3.2 + local-pkg: 0.5.0 + magic-string: 0.30.11 + mlly: 1.7.1 + pathe: 1.1.2 + pkg-types: 1.2.0 + scule: 1.3.0 + strip-literal: 2.1.0 + unplugin: 1.12.2 + transitivePeerDependencies: + - rollup + unimport@3.9.1(rollup@3.29.4): dependencies: '@rollup/pluginutils': 5.1.0(rollup@3.29.4) @@ -10126,6 +10200,13 @@ snapshots: webpack-sources: 3.2.3 webpack-virtual-modules: 0.6.2 + unplugin@1.12.2: + dependencies: + acorn: 8.12.1 + chokidar: 3.6.0 + webpack-sources: 3.2.3 + webpack-virtual-modules: 0.6.2 + unstorage@1.10.2(ioredis@5.4.1): dependencies: anymatch: 3.1.3 @@ -10256,7 +10337,7 @@ snapshots: typescript: 5.5.4 vue-tsc: 2.0.29(typescript@5.5.4) - vite-plugin-inspect@0.8.5(@nuxt/kit@3.12.4(magicast@0.3.4)(rollup@3.29.4))(rollup@3.29.4): + vite-plugin-inspect@0.8.7(@nuxt/kit@3.12.4(magicast@0.3.4)(rollup@3.29.4))(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)): dependencies: '@antfu/utils': 0.7.10 '@rollup/pluginutils': 5.1.0(rollup@3.29.4) @@ -10267,13 +10348,14 @@ snapshots: perfect-debounce: 1.0.0 picocolors: 1.0.1 sirv: 2.0.4 + vite: 5.3.5(@types/node@22.2.0)(terser@5.31.3) optionalDependencies: '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@3.29.4) transitivePeerDependencies: - rollup - supports-color - vite-plugin-inspect@0.8.5(@nuxt/kit@3.12.4(magicast@0.3.4)(rollup@4.19.1))(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)): + vite-plugin-inspect@0.8.7(@nuxt/kit@3.12.4(magicast@0.3.4)(rollup@4.19.1))(rollup@4.19.1)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3)): dependencies: '@antfu/utils': 0.7.10 '@rollup/pluginutils': 5.1.0(rollup@4.19.1) @@ -10316,9 +10398,9 @@ snapshots: fsevents: 2.3.3 terser: 5.31.3 - vitest-environment-nuxt@1.0.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4)): + vitest-environment-nuxt@1.0.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4)): dependencies: - '@nuxt/test-utils': 3.14.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4)) + '@nuxt/test-utils': 3.14.0(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(magicast@0.3.4))(rollup@3.29.4)(vite@5.3.5(@types/node@22.2.0)(terser@5.31.3))(vitest@2.0.5(@types/node@22.2.0)(terser@5.31.3))(vue-router@4.4.0(vue@3.4.34(typescript@5.5.4)))(vue@3.4.34(typescript@5.5.4)) transitivePeerDependencies: - '@cucumber/cucumber' - '@jest/globals' diff --git a/src/runtime/server/lib/oauth/auth0.ts b/src/runtime/server/lib/oauth/auth0.ts index ca938afe..48475f95 100644 --- a/src/runtime/server/lib/oauth/auth0.ts +++ b/src/runtime/server/lib/oauth/auth0.ts @@ -2,6 +2,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -72,12 +73,7 @@ export function oauthAuth0EventHandler({ config, onSuccess, onError }: OAuthConf const { code } = getQuery(event) if (!config.clientId || !config.clientSecret || !config.domain) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_AUTH0_CLIENT_ID or NUXT_OAUTH_AUTH0_CLIENT_SECRET or NUXT_OAUTH_AUTH0_DOMAIN env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'auth0', ['clientId', 'clientSecret', 'domain'], onError) } const authorizationURL = `https://${config.domain}/authorize` const tokenURL = `https://${config.domain}/oauth/token` diff --git a/src/runtime/server/lib/oauth/battledotnet.ts b/src/runtime/server/lib/oauth/battledotnet.ts index 48ee0102..600fae97 100644 --- a/src/runtime/server/lib/oauth/battledotnet.ts +++ b/src/runtime/server/lib/oauth/battledotnet.ts @@ -3,6 +3,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -75,12 +76,8 @@ export function oauthBattledotnetEventHandler({ config, onSuccess, onError }: OA } if (!config.clientId || !config.clientSecret) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_BATTLEDOTNET_CLIENT_ID or NUXT_OAUTH_BATTLEDOTNET_CLIENT_SECRET env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'battledotnet', ['clientId', 'clientSecret'], onError, + ) } const redirectURL = config.redirectURL || getRequestURL(event).href diff --git a/src/runtime/server/lib/oauth/cognito.ts b/src/runtime/server/lib/oauth/cognito.ts index 4bf6b1b4..b01aedb3 100644 --- a/src/runtime/server/lib/oauth/cognito.ts +++ b/src/runtime/server/lib/oauth/cognito.ts @@ -2,6 +2,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -56,12 +57,7 @@ export function oauthCognitoEventHandler({ config, onSuccess, onError }: OAuthCo const { code } = getQuery(event) if (!config.clientId || !config.clientSecret || !config.userPoolId || !config.region) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_COGNITO_CLIENT_ID, NUXT_OAUTH_COGNITO_CLIENT_SECRET, NUXT_OAUTH_COGNITO_USER_POOL_ID, or NUXT_OAUTH_COGNITO_REGION env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'cognito', ['clientId', 'clientSecret', 'userPoolId', 'region'], onError) } const urlBase = config?.domain || `${config.userPoolId}.auth.${config.region}.amazoncognito.com` diff --git a/src/runtime/server/lib/oauth/discord.ts b/src/runtime/server/lib/oauth/discord.ts index 27baaee3..7e3ed8c4 100644 --- a/src/runtime/server/lib/oauth/discord.ts +++ b/src/runtime/server/lib/oauth/discord.ts @@ -2,6 +2,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parseURL, stringifyParsedURL } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -69,12 +70,7 @@ export function oauthDiscordEventHandler({ config, onSuccess, onError }: OAuthCo const { code } = getQuery(event) if (!config.clientId || !config.clientSecret) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_DISCORD_CLIENT_ID or NUXT_OAUTH_DISCORD_CLIENT_SECRET env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'discord', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getRequestURL(event).href diff --git a/src/runtime/server/lib/oauth/facebook.ts b/src/runtime/server/lib/oauth/facebook.ts index 8c4f8fa1..c22a4abf 100644 --- a/src/runtime/server/lib/oauth/facebook.ts +++ b/src/runtime/server/lib/oauth/facebook.ts @@ -8,6 +8,7 @@ import { } from 'h3' import { withQuery } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -86,13 +87,7 @@ export function oauthFacebookEventHandler({ } if (!config.clientId) { - const error = createError({ - statusCode: 500, - message: - 'Missing NUXT_OAUTH_FACEBOOK_CLIENT_ID or NUXT_OAUTH_FACEBOOK_CLIENT_SECRET env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'facebook', ['clientId'], onError) } const redirectURL = config.redirectURL || getRequestURL(event).href diff --git a/src/runtime/server/lib/oauth/github.ts b/src/runtime/server/lib/oauth/github.ts index e949e672..409fe3ee 100644 --- a/src/runtime/server/lib/oauth/github.ts +++ b/src/runtime/server/lib/oauth/github.ts @@ -2,6 +2,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -76,12 +77,7 @@ export function oauthGitHubEventHandler({ config, onSuccess, onError }: OAuthCon } if (!config.clientId || !config.clientSecret) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_GITHUB_CLIENT_ID or NUXT_OAUTH_GITHUB_CLIENT_SECRET env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'github', ['clientId', 'clientSecret'], onError) } if (!query.code) { diff --git a/src/runtime/server/lib/oauth/google.ts b/src/runtime/server/lib/oauth/google.ts index 20a0e5c4..e7ff3da3 100644 --- a/src/runtime/server/lib/oauth/google.ts +++ b/src/runtime/server/lib/oauth/google.ts @@ -8,6 +8,7 @@ import { } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -79,12 +80,7 @@ export function oauthGoogleEventHandler({ const { code } = getQuery(event) if (!config.clientId) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_GOOGLE_CLIENT_ID env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'google', ['clientId'], onError) } const redirectURL = config.redirectURL || getRequestURL(event).href diff --git a/src/runtime/server/lib/oauth/keycloak.ts b/src/runtime/server/lib/oauth/keycloak.ts index 789c20c8..a4f46fc2 100644 --- a/src/runtime/server/lib/oauth/keycloak.ts +++ b/src/runtime/server/lib/oauth/keycloak.ts @@ -8,6 +8,7 @@ import { } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -80,13 +81,7 @@ export function oauthKeycloakEventHandler({ || !config.serverUrl || !config.realm ) { - const error = createError({ - statusCode: 500, - message: - 'Missing NUXT_OAUTH_KEYCLOAK_CLIENT_ID or NUXT_OAUTH_KEYCLOAK_CLIENT_SECRET or NUXT_OAUTH_KEYCLOAK_SERVER_URL or NUXT_OAUTH_KEYCLOAK_REALM env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'keycloak', ['clientId', 'clientSecret', 'serverUrl', 'realm'], onError) } const realmURL = `${config.serverUrl}/realms/${config.realm}` diff --git a/src/runtime/server/lib/oauth/linkedin.ts b/src/runtime/server/lib/oauth/linkedin.ts index b2bceba7..167b004e 100644 --- a/src/runtime/server/lib/oauth/linkedin.ts +++ b/src/runtime/server/lib/oauth/linkedin.ts @@ -2,6 +2,7 @@ import type { H3Event, H3Error } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parseURL, stringifyParsedURL } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' export interface OAuthLinkedInConfig { @@ -66,12 +67,7 @@ export function oauthLinkedInEventHandler({ config, onSuccess, onError }: OAuthC const { code } = getQuery(event) if (!config.clientId || !config.clientSecret) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_LINKEDIN_CLIENT_ID or NUXT_OAUTH_LINKEDIN_CLIENT_SECRET env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'linkedin', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getRequestURL(event).href diff --git a/src/runtime/server/lib/oauth/microsoft.ts b/src/runtime/server/lib/oauth/microsoft.ts index f7e91ad0..8fb497d0 100644 --- a/src/runtime/server/lib/oauth/microsoft.ts +++ b/src/runtime/server/lib/oauth/microsoft.ts @@ -2,6 +2,7 @@ import type { H3Event, H3Error } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' export interface OAuthMicrosoftConfig { @@ -72,12 +73,7 @@ export function oauthMicrosoftEventHandler({ config, onSuccess, onError }: OAuth const { code } = getQuery(event) if (!config.clientId || !config.clientSecret || !config.tenant) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_MICROSOFT_CLIENT_ID or NUXT_OAUTH_MICROSOFT_CLIENT_SECRET or NUXT_OAUTH_MICROSOFT_TENANT env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'microsoft', ['clientId', 'clientSecret', 'tenant'], onError) } const authorizationURL = config.authorizationURL || `https://login.microsoftonline.com/${config.tenant}/oauth2/v2.0/authorize` diff --git a/src/runtime/server/lib/oauth/paypal.ts b/src/runtime/server/lib/oauth/paypal.ts index 70b1de30..8e061c9e 100644 --- a/src/runtime/server/lib/oauth/paypal.ts +++ b/src/runtime/server/lib/oauth/paypal.ts @@ -2,6 +2,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -74,12 +75,7 @@ export function oauthPaypalEventHandler({ config, onSuccess, onError }: OAuthCon const { code } = getQuery(event) if (!config.clientId) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_PAYPAL_CLIENT_ID env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'paypal', ['clientId'], onError) } let paypalAPI = 'api-m.paypal.com' diff --git a/src/runtime/server/lib/oauth/spotify.ts b/src/runtime/server/lib/oauth/spotify.ts index 1f7364c8..1b771099 100644 --- a/src/runtime/server/lib/oauth/spotify.ts +++ b/src/runtime/server/lib/oauth/spotify.ts @@ -2,6 +2,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -64,12 +65,7 @@ export function oauthSpotifyEventHandler({ config, onSuccess, onError }: OAuthCo const { code } = getQuery(event) if (!config.clientId || !config.clientSecret) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_SPOTIFY_CLIENT_ID or NUXT_OAUTH_SPOTIFY_CLIENT_SECRET env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'spotify', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getRequestURL(event).href diff --git a/src/runtime/server/lib/oauth/steam.ts b/src/runtime/server/lib/oauth/steam.ts index 62211840..70f2194b 100644 --- a/src/runtime/server/lib/oauth/steam.ts +++ b/src/runtime/server/lib/oauth/steam.ts @@ -2,6 +2,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -34,12 +35,7 @@ export function oauthSteamEventHandler({ config, onSuccess, onError }: OAuthConf const query: Record = getQuery(event) if (!config.apiKey) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_STEAM_API_KEY env variable.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'steam', ['apiKey'], onError) } if (!query['openid.claimed_id']) { diff --git a/src/runtime/server/lib/oauth/twitch.ts b/src/runtime/server/lib/oauth/twitch.ts index 5b13623a..f4e06612 100644 --- a/src/runtime/server/lib/oauth/twitch.ts +++ b/src/runtime/server/lib/oauth/twitch.ts @@ -2,6 +2,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -67,12 +68,7 @@ export function oauthTwitchEventHandler({ config, onSuccess, onError }: OAuthCon const { code } = getQuery(event) if (!config.clientId) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_TWITCH_CLIENT_ID env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'twitch', ['clientId'], onError) } const redirectURL = config.redirectURL || getRequestURL(event).href diff --git a/src/runtime/server/lib/oauth/x.ts b/src/runtime/server/lib/oauth/x.ts index 594b3d33..235328bb 100644 --- a/src/runtime/server/lib/oauth/x.ts +++ b/src/runtime/server/lib/oauth/x.ts @@ -9,6 +9,7 @@ import { } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -86,12 +87,7 @@ export function oauthXEventHandler({ const { code } = getQuery(event) if (!config.clientId) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_X_CLIENT_ID env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'x', ['clientId'], onError) } const redirectURL = config.redirectURL || getRequestURL(event).href diff --git a/src/runtime/server/lib/oauth/xsuaa.ts b/src/runtime/server/lib/oauth/xsuaa.ts index 80ec2586..5f4bb681 100644 --- a/src/runtime/server/lib/oauth/xsuaa.ts +++ b/src/runtime/server/lib/oauth/xsuaa.ts @@ -2,6 +2,7 @@ import type { H3Event } from 'h3' import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from 'h3' import { withQuery, parsePath } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -41,12 +42,7 @@ export function oauthXSUAAEventHandler({ config, onSuccess, onError }: OAuthConf const { code } = getQuery(event) if (!config.clientId || !config.clientSecret || !config.domain) { - const error = createError({ - statusCode: 500, - message: 'Missing NUXT_OAUTH_XSUAA_CLIENT_ID or NUXT_OAUTH_XSUAA_CLIENT_SECRET or NUXT_OAUTH_XSUAA_DOMAIN env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'xsuaa', ['clientId', 'clientSecret', 'domain'], onError) } const authorizationURL = `https://${config.domain}/oauth/authorize` const tokenURL = `https://${config.domain}/oauth/token` diff --git a/src/runtime/server/lib/oauth/yandex.ts b/src/runtime/server/lib/oauth/yandex.ts index 493c12ef..ee9d0447 100644 --- a/src/runtime/server/lib/oauth/yandex.ts +++ b/src/runtime/server/lib/oauth/yandex.ts @@ -8,6 +8,7 @@ import { } from 'h3' import { withQuery, parseURL, stringifyParsedURL } from 'ufo' import { defu } from 'defu' +import { handleMissingConfiguration } from '../utils' import { useRuntimeConfig } from '#imports' import type { OAuthConfig } from '#auth-utils' @@ -78,13 +79,7 @@ export function oauthYandexEventHandler({ const { code } = getQuery(event) if (!config.clientId || !config.clientSecret) { - const error = createError({ - statusCode: 500, - message: - 'Missing NUXT_OAUTH_YANDEX_CLIENT_ID or NUXT_OAUTH_YANDEX_CLIENT_SECRET env variables.', - }) - if (!onError) throw error - return onError(event, error) + return handleMissingConfiguration(event, 'yandex', ['clientId', 'clientSecret'], onError) } const redirectURL = config.redirectURL || getRequestURL(event).href diff --git a/src/runtime/server/lib/utils.ts b/src/runtime/server/lib/utils.ts new file mode 100644 index 00000000..037befa1 --- /dev/null +++ b/src/runtime/server/lib/utils.ts @@ -0,0 +1,16 @@ +import type { H3Event } from 'h3' +import { snakeCase } from 'scule' +import type { OnError, Provider } from '#auth-utils' +import { createError } from '#imports' + +export function handleMissingConfiguration(event: H3Event, provider: Provider, missingKeys: string[], onError?: OnError) { + const environmentVariables = missingKeys.map(key => `NUXT_OAUTH_${provider.toUpperCase()}_${snakeCase(key).toUpperCase()}`) + + const error = createError({ + statusCode: 500, + message: `Missing ${environmentVariables.join(' or ')} env ${missingKeys.length > 1 ? 'variables' : 'variable'}.`, + }) + + if (!onError) throw error + return onError(event, error) +} diff --git a/src/runtime/types/index.ts b/src/runtime/types/index.ts index 2a759eb9..e4ef66dc 100644 --- a/src/runtime/types/index.ts +++ b/src/runtime/types/index.ts @@ -1,2 +1,2 @@ export type { User, UserSession, UserSessionRequired, UserSessionComposable } from './session' -export type { OAuthConfig } from './oauth-config' +export type { OAuthConfig, OnError, Provider } from './oauth-config' diff --git a/src/runtime/types/oauth-config.ts b/src/runtime/types/oauth-config.ts index c4c07c9d..4a9b8375 100644 --- a/src/runtime/types/oauth-config.ts +++ b/src/runtime/types/oauth-config.ts @@ -1,5 +1,9 @@ import type { H3Event, H3Error } from 'h3' +export type Provider = 'auth0' | 'battledotnet' | 'cognito' | 'discord' | 'facebook' | 'github' | 'google' | 'keycloak' | 'linkedin' | 'microsoft' | 'paypal' | 'spotify' | 'steam' | 'twitch' | 'x' | 'xsuaa' | 'yandex' + +export type OnError = (event: H3Event, error: H3Error) => Promise | void + // eslint-disable-next-line @typescript-eslint/no-explicit-any export interface OAuthConfig { config?: TConfig @@ -7,5 +11,5 @@ export interface OAuthConfig { event: H3Event, result: { user: TUser, tokens: TTokens } ) => Promise | void - onError?: (event: H3Event, error: H3Error) => Promise | void + onError?: OnError }