diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2e0ffeee..68e9e80e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -77,7 +77,7 @@ importers: version: 8.57.0 nuxt: specifier: ^3.12.4 - version: 3.12.4(@parcel/watcher@2.4.1)(@types/node@20.12.7)(encoding@0.1.13)(eslint@8.57.0)(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.3)(rollup@4.19.2)(terser@5.30.3)(typescript@5.5.4)(vite@5.3.3(@types/node@18.19.42)(terser@5.30.3))(vue-tsc@2.0.29(typescript@5.5.4)) + version: 3.12.4(@parcel/watcher@2.4.1)(@types/node@20.12.7)(encoding@0.1.13)(eslint@8.57.0)(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.3)(rollup@4.19.2)(terser@5.30.3)(typescript@5.5.4)(vite@5.3.5(@types/node@20.12.7)(terser@5.30.3))(vue-tsc@2.0.29(typescript@5.5.4)) typescript: specifier: ^5.5.4 version: 5.5.4 @@ -125,43 +125,6 @@ importers: specifier: ^2.0.29 version: 2.0.29(typescript@5.5.4) - playground-refresh: - dependencies: - jsonwebtoken: - specifier: ^9.0.2 - version: 9.0.2 - zod: - specifier: ^3.23.8 - version: 3.23.8 - devDependencies: - '@nuxt/test-utils': - specifier: ^3.14.1 - version: 3.14.1(@playwright/test@1.46.0)(@vue/test-utils@2.4.6)(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(encoding@0.1.13)(magicast@0.3.4))(playwright-core@1.46.0)(rollup@4.19.2)(vite@5.3.5(@types/node@20.12.7)(terser@5.30.3))(vitest@1.6.0(@types/node@20.12.7)(terser@5.30.3))(vue-router@4.4.2(vue@3.4.35(typescript@5.5.4)))(vue@3.4.35(typescript@5.5.4)) - '@playwright/test': - specifier: ^1.46.0 - version: 1.46.0 - '@types/jsonwebtoken': - specifier: ^9.0.6 - version: 9.0.6 - '@vue/test-utils': - specifier: ^2.4.6 - version: 2.4.6 - eslint: - specifier: ^8.57.0 - version: 8.57.0 - nuxt: - specifier: ^3.12.4 - version: 3.12.4(@parcel/watcher@2.4.1)(@types/node@20.12.7)(encoding@0.1.13)(eslint@8.57.0)(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.3)(rollup@4.19.2)(terser@5.30.3)(typescript@5.5.4)(vite@5.3.5(@types/node@20.12.7)(terser@5.30.3))(vue-tsc@2.0.29(typescript@5.5.4)) - typescript: - specifier: ^5.5.4 - version: 5.5.4 - vitest: - specifier: ^1.6.0 - version: 1.6.0(@types/node@20.12.7)(terser@5.30.3) - vue-tsc: - specifier: ^2.0.29 - version: 2.0.29(typescript@5.5.4) - packages: '@aashutoshrathi/word-wrap@1.2.6': @@ -7008,46 +6971,6 @@ snapshots: - rollup - supports-color - '@nuxt/test-utils@3.14.1(@playwright/test@1.46.0)(@vue/test-utils@2.4.6)(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(encoding@0.1.13)(magicast@0.3.4))(playwright-core@1.46.0)(rollup@4.19.2)(vite@5.3.5(@types/node@20.12.7)(terser@5.30.3))(vitest@1.6.0(@types/node@20.12.7)(terser@5.30.3))(vue-router@4.4.2(vue@3.4.35(typescript@5.5.4)))(vue@3.4.35(typescript@5.5.4))': - dependencies: - '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.2) - '@nuxt/schema': 3.12.4(rollup@4.19.2) - c12: 1.11.1(magicast@0.3.4) - consola: 3.2.3 - defu: 6.1.4 - destr: 2.0.3 - estree-walker: 3.0.3 - execa: 8.0.1 - fake-indexeddb: 6.0.0 - get-port-please: 3.1.2 - h3: 1.12.0 - local-pkg: 0.5.0 - magic-string: 0.30.11 - nitropack: 2.9.7(encoding@0.1.13)(magicast@0.3.4) - node-fetch-native: 1.6.4 - ofetch: 1.3.4 - pathe: 1.1.2 - perfect-debounce: 1.0.0 - radix3: 1.1.2 - scule: 1.3.0 - std-env: 3.7.0 - ufo: 1.5.4 - unenv: 1.10.0 - unplugin: 1.12.1 - vite: 5.3.5(@types/node@20.12.7)(terser@5.30.3) - vitest-environment-nuxt: 1.0.0(@playwright/test@1.46.0)(@vue/test-utils@2.4.6)(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(encoding@0.1.13)(magicast@0.3.4))(playwright-core@1.46.0)(rollup@4.19.2)(vite@5.3.5(@types/node@20.12.7)(terser@5.30.3))(vitest@1.6.0(@types/node@20.12.7)(terser@5.30.3))(vue-router@4.4.2(vue@3.4.35(typescript@5.5.4)))(vue@3.4.35(typescript@5.5.4)) - vue: 3.4.35(typescript@5.5.4) - vue-router: 4.4.2(vue@3.4.35(typescript@5.5.4)) - optionalDependencies: - '@playwright/test': 1.46.0 - '@vue/test-utils': 2.4.6 - playwright-core: 1.46.0 - vitest: 1.6.0(@types/node@20.12.7)(terser@5.30.3) - transitivePeerDependencies: - - magicast - - rollup - - supports-color - '@nuxt/vite-builder@3.12.4(@types/node@18.19.42)(eslint@8.57.0)(magicast@0.3.4)(optionator@0.9.3)(rollup@4.19.2)(terser@5.30.3)(typescript@5.5.4)(vue-tsc@2.0.29(typescript@5.5.4))(vue@3.4.35(typescript@5.5.4))': dependencies: '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.2) @@ -10612,112 +10535,6 @@ snapshots: - vue-tsc - xml2js - nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@20.12.7)(encoding@0.1.13)(eslint@8.57.0)(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.3)(rollup@4.19.2)(terser@5.30.3)(typescript@5.5.4)(vite@5.3.3(@types/node@18.19.42)(terser@5.30.3))(vue-tsc@2.0.29(typescript@5.5.4)): - dependencies: - '@nuxt/devalue': 2.0.2 - '@nuxt/devtools': 1.3.9(rollup@4.19.2)(vite@5.3.3(@types/node@18.19.42)(terser@5.30.3)) - '@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.2) - '@nuxt/schema': 3.12.4(rollup@4.19.2) - '@nuxt/telemetry': 2.5.4(magicast@0.3.4)(rollup@4.19.2) - '@nuxt/vite-builder': 3.12.4(@types/node@20.12.7)(eslint@8.57.0)(magicast@0.3.4)(optionator@0.9.3)(rollup@4.19.2)(terser@5.30.3)(typescript@5.5.4)(vue-tsc@2.0.29(typescript@5.5.4))(vue@3.4.35(typescript@5.5.4)) - '@unhead/dom': 1.9.16 - '@unhead/ssr': 1.9.16 - '@unhead/vue': 1.9.16(vue@3.4.35(typescript@5.5.4)) - '@vue/shared': 3.4.35 - acorn: 8.12.1 - c12: 1.11.1(magicast@0.3.4) - chokidar: 3.6.0 - compatx: 0.1.8 - consola: 3.2.3 - cookie-es: 1.1.0 - defu: 6.1.4 - destr: 2.0.3 - devalue: 5.0.0 - errx: 0.1.0 - esbuild: 0.23.0 - escape-string-regexp: 5.0.0 - estree-walker: 3.0.3 - globby: 14.0.2 - h3: 1.12.0 - hookable: 5.5.3 - ignore: 5.3.1 - jiti: 1.21.6 - klona: 2.0.6 - knitwork: 1.1.0 - magic-string: 0.30.10 - mlly: 1.7.1 - nitropack: 2.9.7(encoding@0.1.13)(magicast@0.3.4) - nuxi: 3.12.0 - nypm: 0.3.9 - ofetch: 1.3.4 - ohash: 1.1.3 - pathe: 1.1.2 - perfect-debounce: 1.0.0 - pkg-types: 1.1.3 - radix3: 1.1.2 - scule: 1.3.0 - semver: 7.6.3 - std-env: 3.7.0 - strip-literal: 2.1.0 - ufo: 1.5.4 - ultrahtml: 1.5.3 - uncrypto: 0.1.3 - unctx: 2.3.1 - unenv: 1.10.0 - unimport: 3.9.1(rollup@4.19.2) - unplugin: 1.12.0 - unplugin-vue-router: 0.10.2(rollup@4.19.2)(vue-router@4.4.2(vue@3.4.35(typescript@5.5.4)))(vue@3.4.35(typescript@5.5.4)) - unstorage: 1.10.2(ioredis@5.4.1) - untyped: 1.4.2 - vue: 3.4.35(typescript@5.5.4) - vue-bundle-renderer: 2.1.0 - vue-devtools-stub: 0.1.0 - vue-router: 4.4.2(vue@3.4.35(typescript@5.5.4)) - optionalDependencies: - '@parcel/watcher': 2.4.1 - '@types/node': 20.12.7 - transitivePeerDependencies: - - '@azure/app-configuration' - - '@azure/cosmos' - - '@azure/data-tables' - - '@azure/identity' - - '@azure/keyvault-secrets' - - '@azure/storage-blob' - - '@biomejs/biome' - - '@capacitor/preferences' - - '@libsql/client' - - '@netlify/blobs' - - '@planetscale/database' - - '@upstash/redis' - - '@vercel/kv' - - better-sqlite3 - - bufferutil - - drizzle-orm - - encoding - - eslint - - idb-keyval - - ioredis - - less - - lightningcss - - magicast - - meow - - optionator - - rollup - - sass - - stylelint - - stylus - - sugarss - - supports-color - - terser - - typescript - - uWebSockets.js - - utf-8-validate - - vite - - vls - - vti - - vue-tsc - - xml2js - nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@20.12.7)(encoding@0.1.13)(eslint@8.57.0)(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.3)(rollup@4.19.2)(terser@5.30.3)(typescript@5.5.4)(vite@5.3.5(@types/node@20.12.7)(terser@5.30.3))(vue-tsc@2.0.29(typescript@5.5.4)): dependencies: '@nuxt/devalue': 2.0.2 @@ -12291,23 +12108,6 @@ snapshots: - supports-color - terser - vite-node@1.6.0(@types/node@20.12.7)(terser@5.30.3): - dependencies: - cac: 6.7.14 - debug: 4.3.4 - pathe: 1.1.2 - picocolors: 1.0.0 - vite: 5.2.9(@types/node@20.12.7)(terser@5.30.3) - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - vite-node@2.0.5(@types/node@18.19.42)(terser@5.30.3): dependencies: cac: 6.7.14 @@ -12537,16 +12337,6 @@ snapshots: fsevents: 2.3.3 terser: 5.30.3 - vite@5.2.9(@types/node@20.12.7)(terser@5.30.3): - dependencies: - esbuild: 0.20.2 - postcss: 8.4.38 - rollup: 4.14.3 - optionalDependencies: - '@types/node': 20.12.7 - fsevents: 2.3.3 - terser: 5.30.3 - vite@5.3.3(@types/node@18.19.42)(terser@5.30.3): dependencies: esbuild: 0.21.5 @@ -12657,29 +12447,6 @@ snapshots: - vue - vue-router - vitest-environment-nuxt@1.0.0(@playwright/test@1.46.0)(@vue/test-utils@2.4.6)(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(encoding@0.1.13)(magicast@0.3.4))(playwright-core@1.46.0)(rollup@4.19.2)(vite@5.3.5(@types/node@20.12.7)(terser@5.30.3))(vitest@1.6.0(@types/node@20.12.7)(terser@5.30.3))(vue-router@4.4.2(vue@3.4.35(typescript@5.5.4)))(vue@3.4.35(typescript@5.5.4)): - dependencies: - '@nuxt/test-utils': 3.14.1(@playwright/test@1.46.0)(@vue/test-utils@2.4.6)(h3@1.12.0)(magicast@0.3.4)(nitropack@2.9.7(encoding@0.1.13)(magicast@0.3.4))(playwright-core@1.46.0)(rollup@4.19.2)(vite@5.3.5(@types/node@20.12.7)(terser@5.30.3))(vitest@1.6.0(@types/node@20.12.7)(terser@5.30.3))(vue-router@4.4.2(vue@3.4.35(typescript@5.5.4)))(vue@3.4.35(typescript@5.5.4)) - transitivePeerDependencies: - - '@cucumber/cucumber' - - '@jest/globals' - - '@playwright/test' - - '@testing-library/vue' - - '@vitest/ui' - - '@vue/test-utils' - - h3 - - happy-dom - - jsdom - - magicast - - nitropack - - playwright-core - - rollup - - supports-color - - vite - - vitest - - vue - - vue-router - vitest@1.6.0(@types/node@18.19.44)(terser@5.30.3): dependencies: '@vitest/expect': 1.6.0 @@ -12713,39 +12480,6 @@ snapshots: - supports-color - terser - vitest@1.6.0(@types/node@20.12.7)(terser@5.30.3): - dependencies: - '@vitest/expect': 1.6.0 - '@vitest/runner': 1.6.0 - '@vitest/snapshot': 1.6.0 - '@vitest/spy': 1.6.0 - '@vitest/utils': 1.6.0 - acorn-walk: 8.3.2 - chai: 4.4.1 - debug: 4.3.4 - execa: 8.0.1 - local-pkg: 0.5.0 - magic-string: 0.30.7 - pathe: 1.1.2 - picocolors: 1.0.0 - std-env: 3.7.0 - strip-literal: 2.0.0 - tinybench: 2.6.0 - tinypool: 0.8.4 - vite: 5.2.9(@types/node@20.12.7)(terser@5.30.3) - vite-node: 1.6.0(@types/node@20.12.7)(terser@5.30.3) - why-is-node-running: 2.2.2 - optionalDependencies: - '@types/node': 20.12.7 - transitivePeerDependencies: - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - vscode-jsonrpc@6.0.0: {} vscode-languageclient@7.0.0: diff --git a/src/runtime/composables/local/useAuth.ts b/src/runtime/composables/local/useAuth.ts index bef5f287..b31d7b15 100644 --- a/src/runtime/composables/local/useAuth.ts +++ b/src/runtime/composables/local/useAuth.ts @@ -1,6 +1,6 @@ import { readonly, type Ref } from 'vue' import { callWithNuxt } from '#app/nuxt' -import type { CommonUseAuthReturn, SignOutFunc, SignInFunc, GetSessionFunc, SecondarySignInOptions, SignUpOptions, GetSessionOptions } from '../../types' +import type { CommonUseAuthReturn, SignOutFunc, SignInFunc, GetSessionFunc, SecondarySignInOptions, SignUpOptions, GetSessionOptions, SignUpResponse } from '../../types' import { jsonPointerGet, objectFromJsonPointer, useTypedBackendConfig } from '../../helpers' import { _fetch } from '../../utils/fetch' import { getRequestURLWN } from '../../utils/callWithNuxt' @@ -150,17 +150,20 @@ const getSession: GetSessionFunc = async (getSessionO return data.value } -const signUp = async (credentials: Credentials, signInOptions?: SecondarySignInOptions, signUpOptions?: SignUpOptions) => { +const signUp = async (credentials: Credentials, signInOptions?: SecondarySignInOptions, signUpOptions?: SignUpOptions): Promise => { const nuxt = useNuxtApp() const { path, method } = useTypedBackendConfig(useRuntimeConfig(), 'local').endpoints.signUp - await _fetch(nuxt, path, { + + // Holds result from fetch to be returned if signUpOptions?.preventLoginFlow is true + const result = await _fetch(nuxt, path, { method, body: credentials }) if (signUpOptions?.preventLoginFlow) { - return + // Returns result + return result } return signIn(credentials, signInOptions) diff --git a/src/runtime/types.ts b/src/runtime/types.ts index 851bb251..f8a5cb67 100644 --- a/src/runtime/types.ts +++ b/src/runtime/types.ts @@ -53,6 +53,15 @@ export type SessionDataObject = { | SessionDataObject; }; +/** + * Type of data returned from sign up functiom if preventLoginFlow is true +*/ +export type SignUpResponse = { + id?: string; // Optional id field + token?: string; // Optional token field + [key: string]: any; // Allow additional fields with any type +}; + /** * Available `nuxt-auth` authentication providers. */