nuxt-auth-utils 0.0.6 → 0.0.8

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/README.md CHANGED
@@ -53,13 +53,13 @@ export default defineNuxtConfig({
53
53
  NUXT_SESSION_PASSWORD=password-with-at-least-32-characters
54
54
  ```
55
55
 
56
- Nuxt Auth Core can generate one for you when running Nuxt in development the first time when no `NUXT_SESSION_PASSWORD` is set.
56
+ Nuxt Auth Utils can generate one for you when running Nuxt in development the first time when no `NUXT_SESSION_PASSWORD` is set.
57
57
 
58
58
  4. That's it! You can now add authentication to your Nuxt app ✨
59
59
 
60
60
  ## Vue Composables
61
61
 
62
- Nuxt Neo automatically add some plugins to fetch the current user session to let you access it from your Vue components.
62
+ Nuxt Auth Utils automatically adds some plugins to fetch the current user session to let you access it from your Vue components.
63
63
 
64
64
  ### User Session
65
65
 
@@ -108,7 +108,7 @@ await clearUserSession(event)
108
108
  const session = await requireUserSession(event)
109
109
  ```
110
110
 
111
- You can define the type for your user session by creating a type declaration file (for example, `auth.d.ts`) in your project:
111
+ You can define the type for your user session by creating a type declaration file (for example, `auth.d.ts`) in your project to augment the `UserSession` type:
112
112
 
113
113
  ```ts
114
114
  declare module '#auth-utils' {
@@ -116,6 +116,7 @@ declare module '#auth-utils' {
116
116
  // define the type here
117
117
  }
118
118
  }
119
+ export {}
119
120
  ```
120
121
 
121
122
  ### OAuth Event Handlers
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "auth-utils",
3
3
  "configKey": "auth",
4
- "version": "0.0.6"
4
+ "version": "0.0.8"
5
5
  }
package/dist/module.mjs CHANGED
@@ -17,7 +17,7 @@ const module = defineNuxtModule({
17
17
  console.warn("No session password set, using a random password, please set NUXT_SESSION_PASSWORD in your .env file with at least 32 chars");
18
18
  console.log(`NUXT_SESSION_PASSWORD=${randomPassword}`);
19
19
  }
20
- nuxt.options.alias["#auth-utils"] = resolver.resolve("./runtime/types/auth-utils-session");
20
+ nuxt.options.alias["#auth-utils"] = resolver.resolve("./runtime/types/index");
21
21
  addImportsDir(resolver.resolve("./runtime/composables"));
22
22
  addPlugin(resolver.resolve("./runtime/plugins/session.server"));
23
23
  if (nuxt.options.nitro.imports !== false) {
@@ -52,7 +52,10 @@ const module = defineNuxtModule({
52
52
  const runtimeConfig = nuxt.options.runtimeConfig;
53
53
  runtimeConfig.session = defu(runtimeConfig.session, {
54
54
  name: "nuxt-session",
55
- password: ""
55
+ password: "",
56
+ cookie: {
57
+ sameSite: "lax"
58
+ }
56
59
  });
57
60
  runtimeConfig.oauth = defu(runtimeConfig.oauth, {});
58
61
  runtimeConfig.oauth.github = defu(runtimeConfig.oauth.github, {
@@ -11,7 +11,11 @@ export const useUserSession = () => {
11
11
  };
12
12
  };
13
13
  async function fetch() {
14
- useSessionState().value = await useRequestFetch()("/api/_auth/session").catch(() => ({}));
14
+ useSessionState().value = await useRequestFetch()("/api/_auth/session", {
15
+ headers: {
16
+ Accept: "text/json"
17
+ }
18
+ }).catch(() => ({}));
15
19
  }
16
20
  async function clear() {
17
21
  await $fetch("/api/_auth/session", { method: "DELETE" });
@@ -1,4 +1,4 @@
1
- import type { H3Event, H3Error } from 'h3';
1
+ import type { OAuthConfig } from '#auth-utils';
2
2
  export interface OAuthAuth0Config {
3
3
  /**
4
4
  * Auth0 OAuth Client ID
@@ -33,13 +33,4 @@ export interface OAuthAuth0Config {
33
33
  */
34
34
  emailRequired?: boolean;
35
35
  }
36
- interface OAuthConfig {
37
- config?: OAuthAuth0Config;
38
- onSuccess: (event: H3Event, result: {
39
- user: any;
40
- tokens: any;
41
- }) => Promise<void> | void;
42
- onError?: (event: H3Event, error: H3Error) => Promise<void> | void;
43
- }
44
- export declare function auth0EventHandler({ config, onSuccess, onError }: OAuthConfig): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
45
- export {};
36
+ export declare function auth0EventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthAuth0Config>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
@@ -1,4 +1,4 @@
1
- import type { H3Event, H3Error } from 'h3';
1
+ import type { OAuthConfig } from '#auth-utils';
2
2
  export interface OAuthBattledotnetConfig {
3
3
  /**
4
4
  * Battle.net OAuth Client ID
@@ -35,13 +35,4 @@ export interface OAuthBattledotnetConfig {
35
35
  */
36
36
  tokenURL?: string;
37
37
  }
38
- interface OAuthConfig {
39
- config?: OAuthBattledotnetConfig;
40
- onSuccess: (event: H3Event, result: {
41
- user: any;
42
- tokens: any;
43
- }) => Promise<void> | void;
44
- onError?: (event: H3Event, error: H3Error) => Promise<void> | void;
45
- }
46
- export declare function battledotnetEventHandler({ config, onSuccess, onError }: OAuthConfig): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
47
- export {};
38
+ export declare function battledotnetEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthBattledotnetConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
@@ -1,4 +1,4 @@
1
- import type { H3Event, H3Error } from 'h3';
1
+ import type { OAuthConfig } from '#auth-utils';
2
2
  export interface OAuthDiscordConfig {
3
3
  /**
4
4
  * Discord OAuth Client ID
@@ -39,13 +39,4 @@ export interface OAuthDiscordConfig {
39
39
  */
40
40
  tokenURL?: string;
41
41
  }
42
- interface OAuthConfig {
43
- config?: OAuthDiscordConfig;
44
- onSuccess: (event: H3Event, result: {
45
- user: any;
46
- tokens: any;
47
- }) => Promise<void> | void;
48
- onError?: (event: H3Event, error: H3Error) => Promise<void> | void;
49
- }
50
- export declare function discordEventHandler({ config, onSuccess, onError }: OAuthConfig): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
51
- export {};
42
+ export declare function discordEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthDiscordConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
@@ -1,4 +1,4 @@
1
- import type { H3Event, H3Error } from 'h3';
1
+ import type { OAuthConfig } from '#auth-utils';
2
2
  export interface OAuthGitHubConfig {
3
3
  /**
4
4
  * GitHub OAuth Client ID
@@ -33,13 +33,4 @@ export interface OAuthGitHubConfig {
33
33
  */
34
34
  tokenURL?: string;
35
35
  }
36
- interface OAuthConfig {
37
- config?: OAuthGitHubConfig;
38
- onSuccess: (event: H3Event, result: {
39
- user: any;
40
- tokens: any;
41
- }) => Promise<void> | void;
42
- onError?: (event: H3Event, error: H3Error) => Promise<void> | void;
43
- }
44
- export declare function githubEventHandler({ config, onSuccess, onError }: OAuthConfig): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
45
- export {};
36
+ export declare function githubEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthGitHubConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
@@ -1,4 +1,4 @@
1
- import type { H3Event, H3Error } from 'h3';
1
+ import type { OAuthConfig } from '#auth-utils';
2
2
  export interface OAuthGoogleConfig {
3
3
  /**
4
4
  * Google OAuth Client ID
@@ -33,13 +33,4 @@ export interface OAuthGoogleConfig {
33
33
  */
34
34
  redirectUrl: '/auth/google';
35
35
  }
36
- interface OAuthConfig {
37
- config?: OAuthGoogleConfig;
38
- onSuccess: (event: H3Event, result: {
39
- user: any;
40
- tokens: any;
41
- }) => Promise<void> | void;
42
- onError?: (event: H3Event, error: H3Error) => Promise<void> | void;
43
- }
44
- export declare function googleEventHandler({ config, onSuccess, onError, }: OAuthConfig): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
45
- export {};
36
+ export declare function googleEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGoogleConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
@@ -1,4 +1,4 @@
1
- import type { H3Event, H3Error } from 'h3';
1
+ import type { OAuthConfig } from '#auth-utils';
2
2
  export interface OAuthSpotifyConfig {
3
3
  /**
4
4
  * Spotify OAuth Client ID
@@ -33,13 +33,4 @@ export interface OAuthSpotifyConfig {
33
33
  */
34
34
  tokenURL?: string;
35
35
  }
36
- interface OAuthConfig {
37
- config?: OAuthSpotifyConfig;
38
- onSuccess: (event: H3Event, result: {
39
- user: any;
40
- tokens: any;
41
- }) => Promise<void> | void;
42
- onError?: (event: H3Event, error: H3Error) => Promise<void> | void;
43
- }
44
- export declare function spotifyEventHandler({ config, onSuccess, onError }: OAuthConfig): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
45
- export {};
36
+ export declare function spotifyEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSpotifyConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
@@ -1,4 +1,4 @@
1
- import type { H3Event, H3Error } from 'h3';
1
+ import type { OAuthConfig } from '#auth-utils';
2
2
  export interface OAuthTwitchConfig {
3
3
  /**
4
4
  * Twitch Client ID
@@ -33,13 +33,4 @@ export interface OAuthTwitchConfig {
33
33
  */
34
34
  tokenURL?: string;
35
35
  }
36
- interface OAuthConfig {
37
- config?: OAuthTwitchConfig;
38
- onSuccess: (event: H3Event, result: {
39
- user: any;
40
- tokens: any;
41
- }) => Promise<void> | void;
42
- onError?: (event: H3Event, error: H3Error) => Promise<void> | void;
43
- }
44
- export declare function twitchEventHandler({ config, onSuccess, onError }: OAuthConfig): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
45
- export {};
36
+ export declare function twitchEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthTwitchConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
@@ -0,0 +1,2 @@
1
+ export type { UserSession } from './session';
2
+ export type { OAuthConfig } from './oauth-config';
@@ -0,0 +1,10 @@
1
+ import type { H3Event, H3Error } from 'h3';
2
+ import type { UserSession } from '#auth-utils';
3
+ export interface OAuthConfig<TConfig, TUser = UserSession, TTokens = any> {
4
+ config?: TConfig;
5
+ onSuccess: (event: H3Event, result: {
6
+ user: TUser;
7
+ tokens: TTokens;
8
+ }) => Promise<void> | void;
9
+ onError?: (event: H3Event, error: H3Error) => Promise<void> | void;
10
+ }
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-auth-utils",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Minimalist Auth module for Nuxt with SSR",
5
5
  "repository": "Atinux/nuxt-auth-utils",
6
6
  "license": "MIT",
@@ -30,25 +30,25 @@
30
30
  "test:watch": "vitest watch"
31
31
  },
32
32
  "dependencies": {
33
- "@nuxt/kit": "^3.8.1",
33
+ "@nuxt/kit": "^3.8.2",
34
34
  "defu": "^6.1.3",
35
35
  "ofetch": "^1.3.3",
36
36
  "ohash": "^1.1.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@iconify-json/simple-icons": "^1.1.78",
39
+ "@iconify-json/simple-icons": "^1.1.79",
40
40
  "@nuxt/devtools": "latest",
41
41
  "@nuxt/eslint-config": "^0.2.0",
42
42
  "@nuxt/module-builder": "^0.5.4",
43
- "@nuxt/schema": "^3.8.1",
43
+ "@nuxt/schema": "^3.8.2",
44
44
  "@nuxt/test-utils": "^3.8.1",
45
45
  "@nuxt/ui": "^2.10.0",
46
46
  "@nuxt/ui-pro": "^0.4.2",
47
- "@types/node": "^20.9.0",
47
+ "@types/node": "^20.9.3",
48
48
  "changelogen": "^0.5.5",
49
- "eslint": "^8.53.0",
50
- "nuxt": "^3.8.1",
51
- "typescript": "^5.2.2",
49
+ "eslint": "^8.54.0",
50
+ "nuxt": "^3.8.2",
51
+ "typescript": "^5.3.2",
52
52
  "vitest": "^0.34.6",
53
53
  "vue-tsc": "^1.8.22"
54
54
  }