nuxt-auth-utils 0.0.6 → 0.0.7
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 +4 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +5 -2
- package/dist/runtime/server/lib/oauth/auth0.d.ts +2 -11
- package/dist/runtime/server/lib/oauth/battledotnet.d.ts +2 -11
- package/dist/runtime/server/lib/oauth/discord.d.ts +2 -11
- package/dist/runtime/server/lib/oauth/github.d.ts +2 -11
- package/dist/runtime/server/lib/oauth/google.d.ts +2 -11
- package/dist/runtime/server/lib/oauth/spotify.d.ts +2 -11
- package/dist/runtime/server/lib/oauth/twitch.d.ts +2 -11
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/oauth-config.d.ts +10 -0
- package/dist/runtime/types/oauth-config.mjs +0 -0
- package/dist/runtime/types/session.mjs +0 -0
- package/package.json +1 -1
- /package/dist/runtime/types/{auth-utils-session.mjs → index.mjs} +0 -0
- /package/dist/runtime/types/{auth-utils-session.d.ts → session.d.ts} +0 -0
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
|
|
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
|
|
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
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/
|
|
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, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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,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
|
File without changes
|
|
File without changes
|