nuxt-auth-utils 0.3.0 → 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/README.md +1 -1
- package/dist/module.json +2 -2
- package/dist/runtime/server/api/session.get.d.ts +1 -1
- package/dist/runtime/server/api/session.get.js +5 -3
- package/dist/runtime/server/lib/oauth/auth0.js +2 -4
- package/dist/runtime/server/lib/oauth/battledotnet.js +4 -8
- package/dist/runtime/server/lib/oauth/cognito.js +2 -4
- package/dist/runtime/server/lib/oauth/discord.js +2 -4
- package/dist/runtime/server/lib/oauth/facebook.js +3 -6
- package/dist/runtime/server/lib/oauth/github.js +3 -6
- package/dist/runtime/server/lib/oauth/google.js +2 -4
- package/dist/runtime/server/lib/oauth/keycloak.js +4 -8
- package/dist/runtime/server/lib/oauth/linkedin.js +2 -4
- package/dist/runtime/server/lib/oauth/microsoft.js +3 -6
- package/dist/runtime/server/lib/oauth/paypal.js +3 -6
- package/dist/runtime/server/lib/oauth/spotify.js +2 -4
- package/dist/runtime/server/lib/oauth/steam.js +2 -4
- package/dist/runtime/server/lib/oauth/twitch.js +3 -6
- package/dist/runtime/server/lib/oauth/x.js +3 -6
- package/dist/runtime/server/lib/oauth/xsuaa.js +2 -4
- package/dist/runtime/server/lib/oauth/yandex.js +2 -4
- package/dist/types.d.mts +1 -17
- package/dist/types.d.ts +1 -17
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -157,7 +157,7 @@ export {}
|
|
|
157
157
|
|
|
158
158
|
All handlers can be auto-imported and used in your server routes or API routes.
|
|
159
159
|
|
|
160
|
-
The pattern is `oauth<Provider>EventHandler({ onSuccess, config?, onError? })`, example: `
|
|
160
|
+
The pattern is `oauth<Provider>EventHandler({ onSuccess, config?, onError? })`, example: `oauthGitHubEventHandler`.
|
|
161
161
|
|
|
162
162
|
The helper returns an event handler that automatically redirects to the provider authorization page and then calls `onSuccess` or `onError` depending on the result.
|
|
163
163
|
|
package/dist/module.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<import("
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<import("#auth-utils").UserSession>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { eventHandler } from "h3";
|
|
2
|
-
import {
|
|
2
|
+
import { getUserSession, sessionHooks } from "../utils/session.js";
|
|
3
3
|
export default eventHandler(async (event) => {
|
|
4
|
-
const session = await
|
|
5
|
-
|
|
4
|
+
const session = await getUserSession(event);
|
|
5
|
+
if (session.user) {
|
|
6
|
+
await sessionHooks.callHookParallel("fetch", session, event);
|
|
7
|
+
}
|
|
6
8
|
return session;
|
|
7
9
|
});
|
|
@@ -13,8 +13,7 @@ export function oauthAuth0EventHandler({ config, onSuccess, onError }) {
|
|
|
13
13
|
statusCode: 500,
|
|
14
14
|
message: "Missing NUXT_OAUTH_AUTH0_CLIENT_ID or NUXT_OAUTH_AUTH0_CLIENT_SECRET or NUXT_OAUTH_AUTH0_DOMAIN env variables."
|
|
15
15
|
});
|
|
16
|
-
if (!onError)
|
|
17
|
-
throw error;
|
|
16
|
+
if (!onError) throw error;
|
|
18
17
|
return onError(event, error);
|
|
19
18
|
}
|
|
20
19
|
const authorizationURL = `https://${config.domain}/authorize`;
|
|
@@ -63,8 +62,7 @@ export function oauthAuth0EventHandler({ config, onSuccess, onError }) {
|
|
|
63
62
|
message: `Auth0 login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
64
63
|
data: tokens
|
|
65
64
|
});
|
|
66
|
-
if (!onError)
|
|
67
|
-
throw error;
|
|
65
|
+
if (!onError) throw error;
|
|
68
66
|
return onError(event, error);
|
|
69
67
|
}
|
|
70
68
|
const tokenType = tokens.token_type;
|
|
@@ -18,8 +18,7 @@ export function oauthBattledotnetEventHandler({ config, onSuccess, onError }) {
|
|
|
18
18
|
message: `Battle.net login failed: ${query.error || "Unknown error"}`,
|
|
19
19
|
data: query
|
|
20
20
|
});
|
|
21
|
-
if (!onError)
|
|
22
|
-
throw error;
|
|
21
|
+
if (!onError) throw error;
|
|
23
22
|
return onError(event, error);
|
|
24
23
|
}
|
|
25
24
|
if (!config.clientId || !config.clientSecret) {
|
|
@@ -27,8 +26,7 @@ export function oauthBattledotnetEventHandler({ config, onSuccess, onError }) {
|
|
|
27
26
|
statusCode: 500,
|
|
28
27
|
message: "Missing NUXT_OAUTH_BATTLEDOTNET_CLIENT_ID or NUXT_OAUTH_BATTLEDOTNET_CLIENT_SECRET env variables."
|
|
29
28
|
});
|
|
30
|
-
if (!onError)
|
|
31
|
-
throw error;
|
|
29
|
+
if (!onError) throw error;
|
|
32
30
|
return onError(event, error);
|
|
33
31
|
}
|
|
34
32
|
if (!code) {
|
|
@@ -82,8 +80,7 @@ export function oauthBattledotnetEventHandler({ config, onSuccess, onError }) {
|
|
|
82
80
|
message: `Battle.net login failed: ${tokens.error || "Unknown error"}`,
|
|
83
81
|
data: tokens
|
|
84
82
|
});
|
|
85
|
-
if (!onError)
|
|
86
|
-
throw error;
|
|
83
|
+
if (!onError) throw error;
|
|
87
84
|
return onError(event, error);
|
|
88
85
|
}
|
|
89
86
|
const accessToken = tokens.access_token;
|
|
@@ -99,8 +96,7 @@ export function oauthBattledotnetEventHandler({ config, onSuccess, onError }) {
|
|
|
99
96
|
message: "Could not get Battle.net user",
|
|
100
97
|
data: tokens
|
|
101
98
|
});
|
|
102
|
-
if (!onError)
|
|
103
|
-
throw error;
|
|
99
|
+
if (!onError) throw error;
|
|
104
100
|
return onError(event, error);
|
|
105
101
|
}
|
|
106
102
|
return onSuccess(event, {
|
|
@@ -13,8 +13,7 @@ export function oauthCognitoEventHandler({ config, onSuccess, onError }) {
|
|
|
13
13
|
statusCode: 500,
|
|
14
14
|
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."
|
|
15
15
|
});
|
|
16
|
-
if (!onError)
|
|
17
|
-
throw error;
|
|
16
|
+
if (!onError) throw error;
|
|
18
17
|
return onError(event, error);
|
|
19
18
|
}
|
|
20
19
|
const authorizationURL = `https://${config.userPoolId}.auth.${config.region}.amazoncognito.com/oauth2/authorize`;
|
|
@@ -51,8 +50,7 @@ export function oauthCognitoEventHandler({ config, onSuccess, onError }) {
|
|
|
51
50
|
message: `Cognito login failed: ${tokens.error_description || "Unknown error"}`,
|
|
52
51
|
data: tokens
|
|
53
52
|
});
|
|
54
|
-
if (!onError)
|
|
55
|
-
throw error;
|
|
53
|
+
if (!onError) throw error;
|
|
56
54
|
return onError(event, error);
|
|
57
55
|
}
|
|
58
56
|
const tokenType = tokens.token_type;
|
|
@@ -16,8 +16,7 @@ export function oauthDiscordEventHandler({ config, onSuccess, onError }) {
|
|
|
16
16
|
statusCode: 500,
|
|
17
17
|
message: "Missing NUXT_OAUTH_DISCORD_CLIENT_ID or NUXT_OAUTH_DISCORD_CLIENT_SECRET env variables."
|
|
18
18
|
});
|
|
19
|
-
if (!onError)
|
|
20
|
-
throw error;
|
|
19
|
+
if (!onError) throw error;
|
|
21
20
|
return onError(event, error);
|
|
22
21
|
}
|
|
23
22
|
const redirectUrl = getRequestURL(event).href;
|
|
@@ -66,8 +65,7 @@ export function oauthDiscordEventHandler({ config, onSuccess, onError }) {
|
|
|
66
65
|
message: `Discord login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
67
66
|
data: tokens
|
|
68
67
|
});
|
|
69
|
-
if (!onError)
|
|
70
|
-
throw error;
|
|
68
|
+
if (!onError) throw error;
|
|
71
69
|
return onError(event, error);
|
|
72
70
|
}
|
|
73
71
|
const accessToken = tokens.access_token;
|
|
@@ -26,8 +26,7 @@ export function oauthFacebookEventHandler({
|
|
|
26
26
|
message: `Facebook login failed: ${query.error || "Unknown error"}`,
|
|
27
27
|
data: query
|
|
28
28
|
});
|
|
29
|
-
if (!onError)
|
|
30
|
-
throw error;
|
|
29
|
+
if (!onError) throw error;
|
|
31
30
|
return onError(event, error);
|
|
32
31
|
}
|
|
33
32
|
if (!config.clientId) {
|
|
@@ -35,8 +34,7 @@ export function oauthFacebookEventHandler({
|
|
|
35
34
|
statusCode: 500,
|
|
36
35
|
message: "Missing NUXT_OAUTH_FACEBOOK_CLIENT_ID or NUXT_OAUTH_FACEBOOK_CLIENT_SECRET env variables."
|
|
37
36
|
});
|
|
38
|
-
if (!onError)
|
|
39
|
-
throw error;
|
|
37
|
+
if (!onError) throw error;
|
|
40
38
|
return onError(event, error);
|
|
41
39
|
}
|
|
42
40
|
const redirectUrl = getRequestURL(event).href;
|
|
@@ -66,8 +64,7 @@ export function oauthFacebookEventHandler({
|
|
|
66
64
|
message: `Facebook login failed: ${tokens.error || "Unknown error"}`,
|
|
67
65
|
data: tokens
|
|
68
66
|
});
|
|
69
|
-
if (!onError)
|
|
70
|
-
throw error;
|
|
67
|
+
if (!onError) throw error;
|
|
71
68
|
return onError(event, error);
|
|
72
69
|
}
|
|
73
70
|
const accessToken = tokens.access_token;
|
|
@@ -16,8 +16,7 @@ export function oauthGitHubEventHandler({ config, onSuccess, onError }) {
|
|
|
16
16
|
message: `GitHub login failed: ${query.error || "Unknown error"}`,
|
|
17
17
|
data: query
|
|
18
18
|
});
|
|
19
|
-
if (!onError)
|
|
20
|
-
throw error;
|
|
19
|
+
if (!onError) throw error;
|
|
21
20
|
return onError(event, error);
|
|
22
21
|
}
|
|
23
22
|
if (!config.clientId || !config.clientSecret) {
|
|
@@ -25,8 +24,7 @@ export function oauthGitHubEventHandler({ config, onSuccess, onError }) {
|
|
|
25
24
|
statusCode: 500,
|
|
26
25
|
message: "Missing NUXT_OAUTH_GITHUB_CLIENT_ID or NUXT_OAUTH_GITHUB_CLIENT_SECRET env variables."
|
|
27
26
|
});
|
|
28
|
-
if (!onError)
|
|
29
|
-
throw error;
|
|
27
|
+
if (!onError) throw error;
|
|
30
28
|
return onError(event, error);
|
|
31
29
|
}
|
|
32
30
|
if (!query.code) {
|
|
@@ -62,8 +60,7 @@ export function oauthGitHubEventHandler({ config, onSuccess, onError }) {
|
|
|
62
60
|
message: `GitHub login failed: ${tokens.error || "Unknown error"}`,
|
|
63
61
|
data: tokens
|
|
64
62
|
});
|
|
65
|
-
if (!onError)
|
|
66
|
-
throw error;
|
|
63
|
+
if (!onError) throw error;
|
|
67
64
|
return onError(event, error);
|
|
68
65
|
}
|
|
69
66
|
const accessToken = tokens.access_token;
|
|
@@ -26,8 +26,7 @@ export function oauthGoogleEventHandler({
|
|
|
26
26
|
statusCode: 500,
|
|
27
27
|
message: "Missing NUXT_OAUTH_GOOGLE_CLIENT_ID env variables."
|
|
28
28
|
});
|
|
29
|
-
if (!onError)
|
|
30
|
-
throw error;
|
|
29
|
+
if (!onError) throw error;
|
|
31
30
|
return onError(event, error);
|
|
32
31
|
}
|
|
33
32
|
const redirectUrl = getRequestURL(event).href;
|
|
@@ -63,8 +62,7 @@ export function oauthGoogleEventHandler({
|
|
|
63
62
|
message: `Google login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
64
63
|
data: tokens
|
|
65
64
|
});
|
|
66
|
-
if (!onError)
|
|
67
|
-
throw error;
|
|
65
|
+
if (!onError) throw error;
|
|
68
66
|
return onError(event, error);
|
|
69
67
|
}
|
|
70
68
|
const accessToken = tokens.access_token;
|
|
@@ -25,8 +25,7 @@ export function oauthKeycloakEventHandler({
|
|
|
25
25
|
message: `Keycloak login failed: ${query.error || "Unknown error"}`,
|
|
26
26
|
data: query
|
|
27
27
|
});
|
|
28
|
-
if (!onError)
|
|
29
|
-
throw error;
|
|
28
|
+
if (!onError) throw error;
|
|
30
29
|
return onError(event, error);
|
|
31
30
|
}
|
|
32
31
|
if (!config.clientId || !config.clientSecret || !config.serverUrl || !config.realm) {
|
|
@@ -34,8 +33,7 @@ export function oauthKeycloakEventHandler({
|
|
|
34
33
|
statusCode: 500,
|
|
35
34
|
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."
|
|
36
35
|
});
|
|
37
|
-
if (!onError)
|
|
38
|
-
throw error;
|
|
36
|
+
if (!onError) throw error;
|
|
39
37
|
return onError(event, error);
|
|
40
38
|
}
|
|
41
39
|
const realmURL = `${config.serverUrl}/realms/${config.realm}`;
|
|
@@ -80,8 +78,7 @@ export function oauthKeycloakEventHandler({
|
|
|
80
78
|
message: `Keycloak login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
81
79
|
data: tokens
|
|
82
80
|
});
|
|
83
|
-
if (!onError)
|
|
84
|
-
throw error;
|
|
81
|
+
if (!onError) throw error;
|
|
85
82
|
return onError(event, error);
|
|
86
83
|
}
|
|
87
84
|
const accessToken = tokens.access_token;
|
|
@@ -100,8 +97,7 @@ export function oauthKeycloakEventHandler({
|
|
|
100
97
|
message: "Could not get Keycloak user",
|
|
101
98
|
data: tokens
|
|
102
99
|
});
|
|
103
|
-
if (!onError)
|
|
104
|
-
throw error;
|
|
100
|
+
if (!onError) throw error;
|
|
105
101
|
return onError(event, error);
|
|
106
102
|
}
|
|
107
103
|
return onSuccess(event, {
|
|
@@ -15,8 +15,7 @@ export function oauthLinkedInEventHandler({ config, onSuccess, onError }) {
|
|
|
15
15
|
statusCode: 500,
|
|
16
16
|
message: "Missing NUXT_OAUTH_LINKEDIN_CLIENT_ID or NUXT_OAUTH_LINKEDIN_CLIENT_SECRET env variables."
|
|
17
17
|
});
|
|
18
|
-
if (!onError)
|
|
19
|
-
throw error;
|
|
18
|
+
if (!onError) throw error;
|
|
20
19
|
return onError(event, error);
|
|
21
20
|
}
|
|
22
21
|
const redirectUrl = getRequestURL(event).href;
|
|
@@ -65,8 +64,7 @@ export function oauthLinkedInEventHandler({ config, onSuccess, onError }) {
|
|
|
65
64
|
message: `LinkedIn login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
66
65
|
data: tokens
|
|
67
66
|
});
|
|
68
|
-
if (!onError)
|
|
69
|
-
throw error;
|
|
67
|
+
if (!onError) throw error;
|
|
70
68
|
return onError(event, error);
|
|
71
69
|
}
|
|
72
70
|
const accessToken = tokens.access_token;
|
|
@@ -13,8 +13,7 @@ export function oauthMicrosoftEventHandler({ config, onSuccess, onError }) {
|
|
|
13
13
|
statusCode: 500,
|
|
14
14
|
message: "Missing NUXT_OAUTH_MICROSOFT_CLIENT_ID or NUXT_OAUTH_MICROSOFT_CLIENT_SECRET or NUXT_OAUTH_MICROSOFT_TENANT env variables."
|
|
15
15
|
});
|
|
16
|
-
if (!onError)
|
|
17
|
-
throw error;
|
|
16
|
+
if (!onError) throw error;
|
|
18
17
|
return onError(event, error);
|
|
19
18
|
}
|
|
20
19
|
const authorizationURL = config.authorizationURL || `https://login.microsoftonline.com/${config.tenant}/oauth2/v2.0/authorize`;
|
|
@@ -57,8 +56,7 @@ export function oauthMicrosoftEventHandler({ config, onSuccess, onError }) {
|
|
|
57
56
|
message: `Microsoft login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
58
57
|
data: tokens
|
|
59
58
|
});
|
|
60
|
-
if (!onError)
|
|
61
|
-
throw error;
|
|
59
|
+
if (!onError) throw error;
|
|
62
60
|
return onError(event, error);
|
|
63
61
|
}
|
|
64
62
|
const tokenType = tokens.token_type;
|
|
@@ -77,8 +75,7 @@ export function oauthMicrosoftEventHandler({ config, onSuccess, onError }) {
|
|
|
77
75
|
message: `Microsoft login failed: ${user.error || "Unknown error"}`,
|
|
78
76
|
data: user
|
|
79
77
|
});
|
|
80
|
-
if (!onError)
|
|
81
|
-
throw error;
|
|
78
|
+
if (!onError) throw error;
|
|
82
79
|
return onError(event, error);
|
|
83
80
|
}
|
|
84
81
|
return onSuccess(event, {
|
|
@@ -16,8 +16,7 @@ export function oauthPaypalEventHandler({ config, onSuccess, onError }) {
|
|
|
16
16
|
statusCode: 500,
|
|
17
17
|
message: "Missing NUXT_OAUTH_PAYPAL_CLIENT_ID env variables."
|
|
18
18
|
});
|
|
19
|
-
if (!onError)
|
|
20
|
-
throw error;
|
|
19
|
+
if (!onError) throw error;
|
|
21
20
|
return onError(event, error);
|
|
22
21
|
}
|
|
23
22
|
let paypalAPI = "api-m.paypal.com";
|
|
@@ -71,8 +70,7 @@ export function oauthPaypalEventHandler({ config, onSuccess, onError }) {
|
|
|
71
70
|
message: `PayPal login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
72
71
|
data: tokens
|
|
73
72
|
});
|
|
74
|
-
if (!onError)
|
|
75
|
-
throw error;
|
|
73
|
+
if (!onError) throw error;
|
|
76
74
|
return onError(event, error);
|
|
77
75
|
}
|
|
78
76
|
const accessToken = tokens.access_token;
|
|
@@ -92,8 +90,7 @@ export function oauthPaypalEventHandler({ config, onSuccess, onError }) {
|
|
|
92
90
|
message: "Could not get PayPal user",
|
|
93
91
|
data: tokens
|
|
94
92
|
});
|
|
95
|
-
if (!onError)
|
|
96
|
-
throw error;
|
|
93
|
+
if (!onError) throw error;
|
|
97
94
|
return onError(event, error);
|
|
98
95
|
}
|
|
99
96
|
return onSuccess(event, {
|
|
@@ -15,8 +15,7 @@ export function oauthSpotifyEventHandler({ config, onSuccess, onError }) {
|
|
|
15
15
|
statusCode: 500,
|
|
16
16
|
message: "Missing NUXT_OAUTH_SPOTIFY_CLIENT_ID or NUXT_OAUTH_SPOTIFY_CLIENT_SECRET env variables."
|
|
17
17
|
});
|
|
18
|
-
if (!onError)
|
|
19
|
-
throw error;
|
|
18
|
+
if (!onError) throw error;
|
|
20
19
|
return onError(event, error);
|
|
21
20
|
}
|
|
22
21
|
const redirectUrl = getRequestURL(event).href;
|
|
@@ -60,8 +59,7 @@ export function oauthSpotifyEventHandler({ config, onSuccess, onError }) {
|
|
|
60
59
|
message: `Spotify login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
61
60
|
data: tokens
|
|
62
61
|
});
|
|
63
|
-
if (!onError)
|
|
64
|
-
throw error;
|
|
62
|
+
if (!onError) throw error;
|
|
65
63
|
return onError(event, error);
|
|
66
64
|
}
|
|
67
65
|
const accessToken = tokens.access_token;
|
|
@@ -13,8 +13,7 @@ export function oauthSteamEventHandler({ config, onSuccess, onError }) {
|
|
|
13
13
|
statusCode: 500,
|
|
14
14
|
message: "Missing NUXT_OAUTH_STEAM_API_KEY env variable."
|
|
15
15
|
});
|
|
16
|
-
if (!onError)
|
|
17
|
-
throw error;
|
|
16
|
+
if (!onError) throw error;
|
|
18
17
|
return onError(event, error);
|
|
19
18
|
}
|
|
20
19
|
if (!query["openid.claimed_id"]) {
|
|
@@ -37,8 +36,7 @@ export function oauthSteamEventHandler({ config, onSuccess, onError }) {
|
|
|
37
36
|
statusCode: 401,
|
|
38
37
|
message: "Steam login failed: Unknown error"
|
|
39
38
|
});
|
|
40
|
-
if (!onError)
|
|
41
|
-
throw error;
|
|
39
|
+
if (!onError) throw error;
|
|
42
40
|
return onError(event, error);
|
|
43
41
|
}
|
|
44
42
|
const steamId = query["openid.claimed_id"].split("/").pop();
|
|
@@ -15,8 +15,7 @@ export function oauthTwitchEventHandler({ config, onSuccess, onError }) {
|
|
|
15
15
|
statusCode: 500,
|
|
16
16
|
message: "Missing NUXT_OAUTH_TWITCH_CLIENT_ID env variables."
|
|
17
17
|
});
|
|
18
|
-
if (!onError)
|
|
19
|
-
throw error;
|
|
18
|
+
if (!onError) throw error;
|
|
20
19
|
return onError(event, error);
|
|
21
20
|
}
|
|
22
21
|
const redirectUrl = getRequestURL(event).href;
|
|
@@ -60,8 +59,7 @@ export function oauthTwitchEventHandler({ config, onSuccess, onError }) {
|
|
|
60
59
|
message: `Twitch login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
61
60
|
data: tokens
|
|
62
61
|
});
|
|
63
|
-
if (!onError)
|
|
64
|
-
throw error;
|
|
62
|
+
if (!onError) throw error;
|
|
65
63
|
return onError(event, error);
|
|
66
64
|
}
|
|
67
65
|
const accessToken = tokens.access_token;
|
|
@@ -78,8 +76,7 @@ export function oauthTwitchEventHandler({ config, onSuccess, onError }) {
|
|
|
78
76
|
message: "Could not get Twitch user",
|
|
79
77
|
data: tokens
|
|
80
78
|
});
|
|
81
|
-
if (!onError)
|
|
82
|
-
throw error;
|
|
79
|
+
if (!onError) throw error;
|
|
83
80
|
return onError(event, error);
|
|
84
81
|
}
|
|
85
82
|
return onSuccess(event, {
|
|
@@ -30,8 +30,7 @@ export function oauthXEventHandler({
|
|
|
30
30
|
statusCode: 500,
|
|
31
31
|
message: "Missing NUXT_OAUTH_X_CLIENT_ID env variables."
|
|
32
32
|
});
|
|
33
|
-
if (!onError)
|
|
34
|
-
throw error;
|
|
33
|
+
if (!onError) throw error;
|
|
35
34
|
return onError(event, error);
|
|
36
35
|
}
|
|
37
36
|
const redirectUrl = getRequestURL(event).href;
|
|
@@ -72,8 +71,7 @@ export function oauthXEventHandler({
|
|
|
72
71
|
message: `X login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
73
72
|
data: tokens
|
|
74
73
|
});
|
|
75
|
-
if (!onError)
|
|
76
|
-
throw error;
|
|
74
|
+
if (!onError) throw error;
|
|
77
75
|
return onError(event, error);
|
|
78
76
|
}
|
|
79
77
|
const accessToken = tokens.access_token;
|
|
@@ -109,8 +107,7 @@ export function oauthXEventHandler({
|
|
|
109
107
|
statusCode: 401,
|
|
110
108
|
message: "Twitter login failed: no user email found"
|
|
111
109
|
});
|
|
112
|
-
if (!onError)
|
|
113
|
-
throw error;
|
|
110
|
+
if (!onError) throw error;
|
|
114
111
|
return onError(event, error);
|
|
115
112
|
}
|
|
116
113
|
}
|
|
@@ -11,8 +11,7 @@ export function oauthXSUAAEventHandler({ config, onSuccess, onError }) {
|
|
|
11
11
|
statusCode: 500,
|
|
12
12
|
message: "Missing NUXT_OAUTH_XSUAA_CLIENT_ID or NUXT_OAUTH_XSUAA_CLIENT_SECRET or NUXT_OAUTH_XSUAA_DOMAIN env variables."
|
|
13
13
|
});
|
|
14
|
-
if (!onError)
|
|
15
|
-
throw error;
|
|
14
|
+
if (!onError) throw error;
|
|
16
15
|
return onError(event, error);
|
|
17
16
|
}
|
|
18
17
|
const authorizationURL = `https://${config.domain}/oauth/authorize`;
|
|
@@ -54,8 +53,7 @@ export function oauthXSUAAEventHandler({ config, onSuccess, onError }) {
|
|
|
54
53
|
message: `XSUAA login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
55
54
|
data: tokens
|
|
56
55
|
});
|
|
57
|
-
if (!onError)
|
|
58
|
-
throw error;
|
|
56
|
+
if (!onError) throw error;
|
|
59
57
|
return onError(event, error);
|
|
60
58
|
}
|
|
61
59
|
const tokenType = tokens.token_type;
|
|
@@ -25,8 +25,7 @@ export function oauthYandexEventHandler({
|
|
|
25
25
|
statusCode: 500,
|
|
26
26
|
message: "Missing NUXT_OAUTH_YANDEX_CLIENT_ID or NUXT_OAUTH_YANDEX_CLIENT_SECRET env variables."
|
|
27
27
|
});
|
|
28
|
-
if (!onError)
|
|
29
|
-
throw error;
|
|
28
|
+
if (!onError) throw error;
|
|
30
29
|
return onError(event, error);
|
|
31
30
|
}
|
|
32
31
|
const redirectUrl = getRequestURL(event).href;
|
|
@@ -66,8 +65,7 @@ export function oauthYandexEventHandler({
|
|
|
66
65
|
message: `Yandex login failed: ${tokens.error?.data?.error_description || "Unknown error"}`,
|
|
67
66
|
data: tokens
|
|
68
67
|
});
|
|
69
|
-
if (!onError)
|
|
70
|
-
throw error;
|
|
68
|
+
if (!onError) throw error;
|
|
71
69
|
return onError(event, error);
|
|
72
70
|
}
|
|
73
71
|
const accessToken = tokens.access_token;
|
package/dist/types.d.mts
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ModuleOptions } from './module.js'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare module '@nuxt/schema' {
|
|
7
|
-
interface NuxtConfig { ['auth']?: Partial<ModuleOptions> }
|
|
8
|
-
interface NuxtOptions { ['auth']?: ModuleOptions }
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare module 'nuxt/schema' {
|
|
12
|
-
interface NuxtConfig { ['auth']?: Partial<ModuleOptions> }
|
|
13
|
-
interface NuxtOptions { ['auth']?: ModuleOptions }
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export type { ModuleOptions, default } from './module.js'
|
|
1
|
+
export { type ModuleOptions, default } from './module.js'
|
package/dist/types.d.ts
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ModuleOptions } from './module'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare module '@nuxt/schema' {
|
|
7
|
-
interface NuxtConfig { ['auth']?: Partial<ModuleOptions> }
|
|
8
|
-
interface NuxtOptions { ['auth']?: ModuleOptions }
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare module 'nuxt/schema' {
|
|
12
|
-
interface NuxtConfig { ['auth']?: Partial<ModuleOptions> }
|
|
13
|
-
interface NuxtOptions { ['auth']?: ModuleOptions }
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export type { ModuleOptions, default } from './module'
|
|
1
|
+
export { type ModuleOptions, default } from './module'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-auth-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Minimalist Auth module for Nuxt with SSR",
|
|
5
5
|
"repository": "Atinux/nuxt-auth-utils",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test:watch": "vitest watch"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nuxt/kit": "^3.12.
|
|
35
|
+
"@nuxt/kit": "^3.12.4",
|
|
36
36
|
"defu": "^6.1.4",
|
|
37
37
|
"hookable": "^5.5.3",
|
|
38
38
|
"ofetch": "^1.3.4",
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"uncrypto": "^0.1.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@iconify-json/simple-icons": "^1.1.
|
|
44
|
+
"@iconify-json/simple-icons": "^1.1.111",
|
|
45
45
|
"@nuxt/devtools": "latest",
|
|
46
|
-
"@nuxt/eslint-config": "^0.
|
|
47
|
-
"@nuxt/module-builder": "^0.
|
|
48
|
-
"@nuxt/schema": "^3.12.
|
|
49
|
-
"@nuxt/test-utils": "^3.
|
|
50
|
-
"@nuxt/ui": "^2.
|
|
51
|
-
"@nuxt/ui-pro": "^1.3.
|
|
52
|
-
"@types/node": "^
|
|
46
|
+
"@nuxt/eslint-config": "^0.4.0",
|
|
47
|
+
"@nuxt/module-builder": "^0.8.1",
|
|
48
|
+
"@nuxt/schema": "^3.12.4",
|
|
49
|
+
"@nuxt/test-utils": "^3.14.0",
|
|
50
|
+
"@nuxt/ui": "^2.18.2",
|
|
51
|
+
"@nuxt/ui-pro": "^1.3.1",
|
|
52
|
+
"@types/node": "^22.0.0",
|
|
53
53
|
"changelogen": "^0.5.5",
|
|
54
|
-
"eslint": "^9.
|
|
55
|
-
"nuxt": "^3.12.
|
|
56
|
-
"typescript": "^5.4
|
|
57
|
-
"vitest": "^
|
|
58
|
-
"vue-tsc": "^2.0.
|
|
54
|
+
"eslint": "^9.8.0",
|
|
55
|
+
"nuxt": "^3.12.4",
|
|
56
|
+
"typescript": "^5.5.4",
|
|
57
|
+
"vitest": "^2.0.4",
|
|
58
|
+
"vue-tsc": "^2.0.29"
|
|
59
59
|
}
|
|
60
60
|
}
|