@witchcraft/nuxt-auth 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "auth",
3
3
  "configKey": "auth",
4
- "version": "0.2.2",
4
+ "version": "0.3.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { crop } from '@alanscodelog/utils/crop';
2
2
  import { defineNuxtModule, useLogger, createResolver, addComponentsDir, addImportsDir, addServerScanDir, addServerImportsDir, addServerImports, addTemplate, addRouteMiddleware } from '@nuxt/kit';
3
3
  import { defu } from 'defu';
4
4
 
5
- const module = defineNuxtModule({
5
+ const module$1 = defineNuxtModule({
6
6
  meta: {
7
7
  name: "auth",
8
8
  configKey: "auth"
@@ -79,7 +79,7 @@ const module = defineNuxtModule({
79
79
  options
80
80
  );
81
81
  delete nuxt.options.runtimeConfig.public.auth.useGlobalMiddleware;
82
- nuxt.options.alias["#auth"] = resolve("runtime");
82
+ nuxt.options.alias["#witchcraft-nuxt-auth"] = resolve("runtime");
83
83
  addImportsDir(resolve("runtime/composables"));
84
84
  addImportsDir(resolve("runtime/utils"));
85
85
  addServerScanDir(resolve("runtime/server"));
@@ -134,4 +134,4 @@ const module = defineNuxtModule({
134
134
  }
135
135
  });
136
136
 
137
- export { module as default };
137
+ export { module$1 as default };
@@ -5,12 +5,12 @@ type __VLS_Props = {
5
5
  useAuthOptions?: UseAuthComposableOptions;
6
6
  loginOptions?: Parameters<ReturnType<typeof useAuth>["login"]>[1];
7
7
  };
8
- declare var __VLS_19: {
8
+ declare var __VLS_20: {
9
9
  class: string;
10
10
  iconClass: string;
11
11
  };
12
12
  type __VLS_Slots = {} & {
13
- extra?: (props: typeof __VLS_19) => any;
13
+ extra?: (props: typeof __VLS_20) => any;
14
14
  };
15
15
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
16
  providerStyles: Record<ProviderNames, Partial<ProviderStyle>>;
@@ -5,12 +5,12 @@ type __VLS_Props = {
5
5
  useAuthOptions?: UseAuthComposableOptions;
6
6
  loginOptions?: Parameters<ReturnType<typeof useAuth>["login"]>[1];
7
7
  };
8
- declare var __VLS_19: {
8
+ declare var __VLS_20: {
9
9
  class: string;
10
10
  iconClass: string;
11
11
  };
12
12
  type __VLS_Slots = {} & {
13
- extra?: (props: typeof __VLS_19) => any;
13
+ extra?: (props: typeof __VLS_20) => any;
14
14
  };
15
15
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
16
  providerStyles: Record<ProviderNames, Partial<ProviderStyle>>;
@@ -4,24 +4,48 @@ type __VLS_Props = {
4
4
  usernameLink?: (user: AuthUser) => string;
5
5
  };
6
6
  declare var __VLS_1: {
7
- user: any;
8
- authRoutes: any;
7
+ user: AuthUser;
8
+ authRoutes: {
9
+ login: string | undefined;
10
+ unauthenticated?: string | undefined;
11
+ register?: string | undefined;
12
+ postRegisteredLogin?: string | undefined;
13
+ externalCode?: string | undefined;
14
+ deeplink?: string | undefined;
15
+ mockAuth?: string | undefined;
16
+ };
9
17
  }, __VLS_3: {
10
- user: any;
11
- }, __VLS_18: {
12
- user: any;
13
- authRoutes: any;
14
- }, __VLS_33: {
15
- authRoutes: any;
18
+ user: AuthUser;
19
+ }, __VLS_19: {
20
+ user: AuthUser;
21
+ authRoutes: {
22
+ login: string | undefined;
23
+ unauthenticated?: string | undefined;
24
+ register?: string | undefined;
25
+ postRegisteredLogin?: string | undefined;
26
+ externalCode?: string | undefined;
27
+ deeplink?: string | undefined;
28
+ mockAuth?: string | undefined;
29
+ };
30
+ }, __VLS_35: {
31
+ authRoutes: {
32
+ login: string | undefined;
33
+ unauthenticated?: string | undefined;
34
+ register?: string | undefined;
35
+ postRegisteredLogin?: string | undefined;
36
+ externalCode?: string | undefined;
37
+ deeplink?: string | undefined;
38
+ mockAuth?: string | undefined;
39
+ };
16
40
  };
17
41
  type __VLS_Slots = {} & {
18
42
  'authenticated-registered'?: (props: typeof __VLS_1) => any;
19
43
  } & {
20
44
  user?: (props: typeof __VLS_3) => any;
21
45
  } & {
22
- 'authenticated-unregistered'?: (props: typeof __VLS_18) => any;
46
+ 'authenticated-unregistered'?: (props: typeof __VLS_19) => any;
23
47
  } & {
24
- unauthenticated?: (props: typeof __VLS_33) => any;
48
+ unauthenticated?: (props: typeof __VLS_35) => any;
25
49
  };
26
50
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
27
51
  usernameLink: (user: AuthUser) => string;
@@ -4,24 +4,48 @@ type __VLS_Props = {
4
4
  usernameLink?: (user: AuthUser) => string;
5
5
  };
6
6
  declare var __VLS_1: {
7
- user: any;
8
- authRoutes: any;
7
+ user: AuthUser;
8
+ authRoutes: {
9
+ login: string | undefined;
10
+ unauthenticated?: string | undefined;
11
+ register?: string | undefined;
12
+ postRegisteredLogin?: string | undefined;
13
+ externalCode?: string | undefined;
14
+ deeplink?: string | undefined;
15
+ mockAuth?: string | undefined;
16
+ };
9
17
  }, __VLS_3: {
10
- user: any;
11
- }, __VLS_18: {
12
- user: any;
13
- authRoutes: any;
14
- }, __VLS_33: {
15
- authRoutes: any;
18
+ user: AuthUser;
19
+ }, __VLS_19: {
20
+ user: AuthUser;
21
+ authRoutes: {
22
+ login: string | undefined;
23
+ unauthenticated?: string | undefined;
24
+ register?: string | undefined;
25
+ postRegisteredLogin?: string | undefined;
26
+ externalCode?: string | undefined;
27
+ deeplink?: string | undefined;
28
+ mockAuth?: string | undefined;
29
+ };
30
+ }, __VLS_35: {
31
+ authRoutes: {
32
+ login: string | undefined;
33
+ unauthenticated?: string | undefined;
34
+ register?: string | undefined;
35
+ postRegisteredLogin?: string | undefined;
36
+ externalCode?: string | undefined;
37
+ deeplink?: string | undefined;
38
+ mockAuth?: string | undefined;
39
+ };
16
40
  };
17
41
  type __VLS_Slots = {} & {
18
42
  'authenticated-registered'?: (props: typeof __VLS_1) => any;
19
43
  } & {
20
44
  user?: (props: typeof __VLS_3) => any;
21
45
  } & {
22
- 'authenticated-unregistered'?: (props: typeof __VLS_18) => any;
46
+ 'authenticated-unregistered'?: (props: typeof __VLS_19) => any;
23
47
  } & {
24
- unauthenticated?: (props: typeof __VLS_33) => any;
48
+ unauthenticated?: (props: typeof __VLS_35) => any;
25
49
  };
26
50
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
27
51
  usernameLink: (user: AuthUser) => string;
@@ -6,20 +6,20 @@ type __VLS_Props = {
6
6
  onSubmitRegistration?: (event: Event, username: string, error: Ref<string>, redirectUrl: string, deeplink?: string) => void;
7
7
  id?: string;
8
8
  };
9
- declare var __VLS_17: {}, __VLS_24: {}, __VLS_31: {}, __VLS_38: {}, __VLS_45: {
10
- error: any;
11
- registrationError: any;
9
+ declare var __VLS_20: {}, __VLS_27: {}, __VLS_34: {}, __VLS_41: {}, __VLS_49: {
10
+ error: import("nuxt/app").NuxtError<unknown> | undefined;
11
+ registrationError: string;
12
12
  };
13
13
  type __VLS_Slots = {} & {
14
- 'username-icon-loading'?: (props: typeof __VLS_17) => any;
14
+ 'username-icon-loading'?: (props: typeof __VLS_20) => any;
15
15
  } & {
16
- 'username-icon-valid'?: (props: typeof __VLS_24) => any;
16
+ 'username-icon-valid'?: (props: typeof __VLS_27) => any;
17
17
  } & {
18
- 'username-icon-invalid'?: (props: typeof __VLS_31) => any;
18
+ 'username-icon-invalid'?: (props: typeof __VLS_34) => any;
19
19
  } & {
20
- default?: (props: typeof __VLS_38) => any;
20
+ default?: (props: typeof __VLS_41) => any;
21
21
  } & {
22
- error?: (props: typeof __VLS_45) => any;
22
+ error?: (props: typeof __VLS_49) => any;
23
23
  };
24
24
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
25
25
  debounce: number;
@@ -6,20 +6,20 @@ type __VLS_Props = {
6
6
  onSubmitRegistration?: (event: Event, username: string, error: Ref<string>, redirectUrl: string, deeplink?: string) => void;
7
7
  id?: string;
8
8
  };
9
- declare var __VLS_17: {}, __VLS_24: {}, __VLS_31: {}, __VLS_38: {}, __VLS_45: {
10
- error: any;
11
- registrationError: any;
9
+ declare var __VLS_20: {}, __VLS_27: {}, __VLS_34: {}, __VLS_41: {}, __VLS_49: {
10
+ error: import("nuxt/app").NuxtError<unknown> | undefined;
11
+ registrationError: string;
12
12
  };
13
13
  type __VLS_Slots = {} & {
14
- 'username-icon-loading'?: (props: typeof __VLS_17) => any;
14
+ 'username-icon-loading'?: (props: typeof __VLS_20) => any;
15
15
  } & {
16
- 'username-icon-valid'?: (props: typeof __VLS_24) => any;
16
+ 'username-icon-valid'?: (props: typeof __VLS_27) => any;
17
17
  } & {
18
- 'username-icon-invalid'?: (props: typeof __VLS_31) => any;
18
+ 'username-icon-invalid'?: (props: typeof __VLS_34) => any;
19
19
  } & {
20
- default?: (props: typeof __VLS_38) => any;
20
+ default?: (props: typeof __VLS_41) => any;
21
21
  } & {
22
- error?: (props: typeof __VLS_45) => any;
22
+ error?: (props: typeof __VLS_49) => any;
23
23
  };
24
24
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
25
25
  debounce: number;
@@ -2,8 +2,8 @@ import type { AuthUser, ProviderNames, UseAuthComposableOptions } from "../types
2
2
  type AuthListenerHook = () => void;
3
3
  type AuthListenerHooks = "beforeLogout";
4
4
  export declare const useAuth: ({ handleActions }?: UseAuthComposableOptions) => {
5
- on: (hook: AuthListenerHooks, listener: AuthListenerHook) => Promise<void>;
6
- off: (hook: AuthListenerHooks, listener: AuthListenerHook) => Promise<void>;
5
+ on: (hook: AuthListenerHooks, listener: AuthListenerHook) => void;
6
+ off: (hook: AuthListenerHooks, listener: AuthListenerHook) => void;
7
7
  user: import("vue").Ref<AuthUser | null, AuthUser | null>;
8
8
  setFetchUserOnNavigation: (value?: boolean) => void;
9
9
  login: (provider: ProviderNames, { devBypass }?: {
@@ -50,10 +50,10 @@ export const useAuth = ({ handleActions } = {}) => {
50
50
  }
51
51
  }
52
52
  }
53
- async function on(hook, listener) {
53
+ function on(hook, listener) {
54
54
  hooks[hook].push(listener);
55
55
  }
56
- async function off(hook, listener) {
56
+ function off(hook, listener) {
57
57
  const index = hooks[hook].indexOf(listener);
58
58
  if (index > -1) {
59
59
  hooks[hook].splice(index, 1);
@@ -13,10 +13,11 @@ export default defineNuxtRouteMiddleware(async (_to, _from) => {
13
13
  if (import.meta.client && import.meta.dev) {
14
14
  console.log({ ns: "auth:middleware:authGlobal", doFetch: doFetch.value, userData: userData.value });
15
15
  }
16
- if (!doFetch.value) return;
17
- const res = await useFetch(getAuthApiRoute(useRuntimeConfig().public, "usersInfo"));
18
- doFetch.value = false;
19
- userData.value = res.data.value;
16
+ if (doFetch.value) {
17
+ const res = await useFetch(getAuthApiRoute(useRuntimeConfig().public, "usersInfo"));
18
+ doFetch.value = false;
19
+ userData.value = res.data.value;
20
+ }
20
21
  if (import.meta.client && !userData.value) {
21
22
  const user = jsonSafeParse(localStorage.getItem("auth:user") ?? "null");
22
23
  if (user.isOk && user.value) {
@@ -1,4 +1,4 @@
1
- import type { BaseLogger } from "@witchcraft/nuxt-logger/shared/createUseLogger";
1
+ import type { BaseLogger } from "@witchcraft/nuxt-logger/types";
2
2
  import { type OAuth2RequestError, type OAuth2Tokens } from "arctic";
3
3
  import type { CookieSerializeOptions } from "cookie-es";
4
4
  import type { PgDatabase } from "drizzle-orm/pg-core";
@@ -1,4 +1,4 @@
1
- import type { BaseLogger } from "@witchcraft/nuxt-logger/shared/createUseLogger";
1
+ import type { BaseLogger } from "@witchcraft/nuxt-logger/types";
2
2
  import type { PgDatabase } from "drizzle-orm/pg-core";
3
3
  import type { PgliteDatabase } from "drizzle-orm/pglite";
4
4
  import type { EventHandler } from "h3";
@@ -1,4 +1,4 @@
1
- import type { BaseLogger } from "@witchcraft/nuxt-logger/shared/createUseLogger";
1
+ import type { BaseLogger } from "@witchcraft/nuxt-logger/types";
2
2
  import type { SessionManager } from "./SessionManager.js";
3
3
  import type { AuthSession, AuthUser } from "../../types.js";
4
4
  export declare function createAuthMiddleware(sessionManager: SessionManager, logger: BaseLogger): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@witchcraft/nuxt-auth",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "Nuxt module for logging.",
5
5
  "repository": "witchcraftjs/nuxt-auth",
6
6
  "license": "MIT",
@@ -32,16 +32,16 @@
32
32
  }
33
33
  },
34
34
  "dependencies": {
35
- "@alanscodelog/tsconfigs": "^6.2.0",
36
- "@alanscodelog/utils": "^6.0.2",
35
+ "@alanscodelog/tsconfigs": "^6.3.0",
36
+ "@alanscodelog/utils": "^6.2.0",
37
37
  "@iconify/json": "^2.2.393",
38
38
  "@nuxt/kit": "^4.1.3",
39
39
  "@oslojs/crypto": "^1.0.1",
40
40
  "@oslojs/encoding": "^1.1.0",
41
41
  "@types/jsonwebtoken": "^9.0.10",
42
42
  "@vueuse/core": "^13.9.0",
43
- "@witchcraft/nuxt-logger": "^0.0.9",
44
- "@witchcraft/ui": "^0.3.7",
43
+ "@witchcraft/nuxt-logger": "^0.0.11",
44
+ "@witchcraft/ui": "^0.3.24",
45
45
  "arctic": "^3.7.0",
46
46
  "cookie-es": "^2.0.0",
47
47
  "defu": "^6.1.4",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@alanscodelog/eslint-config": "^6.3.1",
58
- "@alanscodelog/semantic-release-config": "^6.0.0",
58
+ "@alanscodelog/semantic-release-config": "^6.0.2",
59
59
  "@commitlint/cli": "^20.1.0",
60
60
  "@nuxt/eslint-config": "^1.9.0",
61
61
  "@nuxt/module-builder": "^1.0.2",
@@ -69,7 +69,7 @@
69
69
  "electron": "^38.2.2",
70
70
  "eslint": "^9.37.0",
71
71
  "husky": "^9.1.7",
72
- "nuxt": "^4.1.3",
72
+ "nuxt": "^4.2.1",
73
73
  "reka-ui": "^2.5.1",
74
74
  "tailwindcss": "^4.1.14",
75
75
  "typescript": "^5.9.3",