nuxt-auth-utils 0.5.34 → 0.6.0
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 +89 -15
- package/dist/module.d.mts +3 -3
- package/dist/module.json +4 -1
- package/dist/module.mjs +18 -31
- package/dist/runtime/app/composables/session.js +3 -2
- package/dist/runtime/server/api/session.delete.d.ts +1 -1
- package/dist/runtime/server/api/session.delete.js +2 -2
- package/dist/runtime/server/api/session.get.d.ts +1 -1
- package/dist/runtime/server/api/session.get.js +2 -2
- package/dist/runtime/server/lib/atproto/bluesky.d.ts +3 -3
- package/dist/runtime/server/lib/atproto/bluesky.js +6 -6
- package/dist/runtime/server/lib/oauth/apple.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/apple.js +3 -4
- package/dist/runtime/server/lib/oauth/atlassian.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/atlassian.js +8 -8
- package/dist/runtime/server/lib/oauth/auth0.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/auth0.js +4 -4
- package/dist/runtime/server/lib/oauth/authentik.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/authentik.js +6 -6
- package/dist/runtime/server/lib/oauth/azureb2c.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/azureb2c.js +5 -5
- package/dist/runtime/server/lib/oauth/battledotnet.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/battledotnet.js +6 -6
- package/dist/runtime/server/lib/oauth/box.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/box.js +5 -5
- package/dist/runtime/server/lib/oauth/cloudflare.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/cloudflare.js +5 -5
- package/dist/runtime/server/lib/oauth/cognito.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/cognito.js +4 -4
- package/dist/runtime/server/lib/oauth/discord.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/discord.js +4 -4
- package/dist/runtime/server/lib/oauth/dropbox.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/dropbox.js +5 -5
- package/dist/runtime/server/lib/oauth/facebook.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/facebook.js +7 -7
- package/dist/runtime/server/lib/oauth/gitea.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/gitea.js +5 -5
- package/dist/runtime/server/lib/oauth/github.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/github.js +6 -6
- package/dist/runtime/server/lib/oauth/gitlab.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/gitlab.js +5 -5
- package/dist/runtime/server/lib/oauth/google.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/google.js +4 -4
- package/dist/runtime/server/lib/oauth/heroku.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/heroku.js +5 -5
- package/dist/runtime/server/lib/oauth/hubspot.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/hubspot.js +4 -4
- package/dist/runtime/server/lib/oauth/instagram.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/instagram.js +6 -6
- package/dist/runtime/server/lib/oauth/keycloak.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/keycloak.js +6 -6
- package/dist/runtime/server/lib/oauth/kick.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/kick.js +5 -5
- package/dist/runtime/server/lib/oauth/line.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/line.js +6 -6
- package/dist/runtime/server/lib/oauth/linear.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/linear.js +6 -6
- package/dist/runtime/server/lib/oauth/linkedin.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/linkedin.js +4 -4
- package/dist/runtime/server/lib/oauth/livechat.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/livechat.js +4 -4
- package/dist/runtime/server/lib/oauth/mastodon.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/mastodon.js +8 -9
- package/dist/runtime/server/lib/oauth/microsoft.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/microsoft.js +5 -5
- package/dist/runtime/server/lib/oauth/oidc.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/oidc.js +6 -6
- package/dist/runtime/server/lib/oauth/okta.d.ts +4 -4
- package/dist/runtime/server/lib/oauth/okta.js +8 -8
- package/dist/runtime/server/lib/oauth/ory.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/ory.js +6 -6
- package/dist/runtime/server/lib/oauth/osu.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/osu.js +4 -4
- package/dist/runtime/server/lib/oauth/paypal.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/paypal.js +5 -5
- package/dist/runtime/server/lib/oauth/polar.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/polar.js +5 -5
- package/dist/runtime/server/lib/oauth/riotgames.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/riotgames.js +5 -5
- package/dist/runtime/server/lib/oauth/roblox.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/roblox.js +4 -4
- package/dist/runtime/server/lib/oauth/salesforce.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/salesforce.js +5 -5
- package/dist/runtime/server/lib/oauth/seznam.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/seznam.js +4 -4
- package/dist/runtime/server/lib/oauth/shopifyCustomer.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/shopifyCustomer.js +7 -7
- package/dist/runtime/server/lib/oauth/slack.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/slack.js +5 -5
- package/dist/runtime/server/lib/oauth/spotify.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/spotify.js +4 -4
- package/dist/runtime/server/lib/oauth/steam.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/steam.js +7 -7
- package/dist/runtime/server/lib/oauth/strava.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/strava.js +5 -5
- package/dist/runtime/server/lib/oauth/tiktok.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/tiktok.js +5 -5
- package/dist/runtime/server/lib/oauth/twitch.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/twitch.js +5 -5
- package/dist/runtime/server/lib/oauth/vk.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/vk.js +5 -5
- package/dist/runtime/server/lib/oauth/wechat.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/wechat.js +7 -7
- package/dist/runtime/server/lib/oauth/workos.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/workos.js +3 -4
- package/dist/runtime/server/lib/oauth/x.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/x.js +4 -4
- package/dist/runtime/server/lib/oauth/xsuaa.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/xsuaa.js +4 -4
- package/dist/runtime/server/lib/oauth/yandex.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/yandex.js +4 -4
- package/dist/runtime/server/lib/oauth/zendesk.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/zendesk.js +4 -4
- package/dist/runtime/server/lib/oauth/zitadel.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/zitadel.js +6 -6
- package/dist/runtime/server/lib/utils.d.ts +8 -8
- package/dist/runtime/server/lib/utils.js +5 -7
- package/dist/runtime/server/lib/webauthn/authenticate.d.ts +1 -1
- package/dist/runtime/server/lib/webauthn/authenticate.js +7 -8
- package/dist/runtime/server/lib/webauthn/register.d.ts +2 -2
- package/dist/runtime/server/lib/webauthn/register.js +9 -10
- package/dist/runtime/server/plugins/oauth-hash.d.ts +2 -0
- package/dist/runtime/server/plugins/oauth-hash.js +8 -0
- package/dist/runtime/server/routes/atproto/client-metadata.json.get.d.ts +1 -1
- package/dist/runtime/server/routes/atproto/client-metadata.json.get.js +5 -5
- package/dist/runtime/server/utils/atproto.d.ts +2 -2
- package/dist/runtime/server/utils/atproto.js +2 -3
- package/dist/runtime/server/utils/password.js +1 -1
- package/dist/runtime/server/utils/session.d.ts +29 -16
- package/dist/runtime/server/utils/session.js +72 -29
- package/dist/runtime/types/event.d.ts +27 -3
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/types/oauth-config.d.ts +3 -3
- package/dist/runtime/types/webauthn.d.ts +14 -17
- package/package.json +10 -6
- package/dist/runtime/server/plugins/oauth.d.ts +0 -2
- package/dist/runtime/server/plugins/oauth.js +0 -16
- package/dist/runtime/server/plugins/ws.d.ts +0 -2
- package/dist/runtime/server/plugins/ws.js +0 -7
|
@@ -45,4 +45,4 @@ export interface OAuthBattledotnetConfig {
|
|
|
45
45
|
*/
|
|
46
46
|
redirectURL?: string;
|
|
47
47
|
}
|
|
48
|
-
export declare function defineOAuthBattledotnetEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthBattledotnetConfig>): import("
|
|
48
|
+
export declare function defineOAuthBattledotnetEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthBattledotnetConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
6
6
|
export function defineOAuthBattledotnetEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.battledotnet, {
|
|
9
9
|
authorizationURL: "https://oauth.battle.net/authorize",
|
|
10
10
|
tokenURL: "https://oauth.battle.net/token",
|
|
11
11
|
authorizationParams: {}
|
|
@@ -13,7 +13,7 @@ export function defineOAuthBattledotnetEventHandler({ config, onSuccess, onError
|
|
|
13
13
|
const query = getQuery(event);
|
|
14
14
|
if (query.error) {
|
|
15
15
|
const error = createError({
|
|
16
|
-
|
|
16
|
+
status: 401,
|
|
17
17
|
message: `Battle.net login failed: ${query.error || "Unknown error"}`,
|
|
18
18
|
data: query
|
|
19
19
|
});
|
|
@@ -79,7 +79,7 @@ export function defineOAuthBattledotnetEventHandler({ config, onSuccess, onError
|
|
|
79
79
|
});
|
|
80
80
|
if (!user) {
|
|
81
81
|
const error = createError({
|
|
82
|
-
|
|
82
|
+
status: 500,
|
|
83
83
|
message: "Could not get Battle.net user",
|
|
84
84
|
data: tokens
|
|
85
85
|
});
|
|
@@ -91,5 +91,5 @@ interface OAuthBoxTokens {
|
|
|
91
91
|
export declare function defineOAuthBoxEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthBoxConfig, {
|
|
92
92
|
user: OAuthBoxUser;
|
|
93
93
|
tokens: OAuthBoxTokens;
|
|
94
|
-
}>): import("
|
|
94
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
95
95
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { getOAuthRedirectURL, handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthBoxEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.box, {
|
|
9
9
|
authorizationURL: "https://account.box.com/api/oauth2/authorize",
|
|
10
10
|
tokenURL: "https://api.box.com/oauth2/token",
|
|
11
11
|
userURL: "https://api.box.com/2.0/users/me",
|
|
@@ -15,7 +15,7 @@ export function defineOAuthBoxEventHandler({ config, onSuccess, onError }) {
|
|
|
15
15
|
if (query.error) {
|
|
16
16
|
const errorMessageParts = [query.error, query.error_description].filter(Boolean).join(": ");
|
|
17
17
|
const error = createError({
|
|
18
|
-
|
|
18
|
+
status: 401,
|
|
19
19
|
message: `Box login failed: ${errorMessageParts || "Unknown error"}`,
|
|
20
20
|
data: query
|
|
21
21
|
});
|
|
@@ -83,4 +83,4 @@ export interface CloudflareTokens {
|
|
|
83
83
|
export declare function defineOAuthCloudflareEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthCloudflareConfig, {
|
|
84
84
|
user: CloudflareUser;
|
|
85
85
|
tokens: CloudflareTokens;
|
|
86
|
-
}>): import("
|
|
86
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { getOAuthRedirectURL, handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, handlePkceVerifier, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthCloudflareEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.cloudflare, {
|
|
9
9
|
authorizationURL: "https://dash.cloudflare.com/oauth2/auth",
|
|
10
10
|
tokenURL: "https://dash.cloudflare.com/oauth2/token",
|
|
11
11
|
userURL: "https://dash.cloudflare.com/oauth2/userinfo",
|
|
@@ -14,7 +14,7 @@ export function defineOAuthCloudflareEventHandler({ config, onSuccess, onError }
|
|
|
14
14
|
const query = getQuery(event);
|
|
15
15
|
if (query.error) {
|
|
16
16
|
const error = createError({
|
|
17
|
-
|
|
17
|
+
status: 401,
|
|
18
18
|
message: `Cloudflare login failed: ${query.error_description || query.error}`,
|
|
19
19
|
data: query
|
|
20
20
|
});
|
|
@@ -36,4 +36,4 @@ export interface OAuthCognitoConfig {
|
|
|
36
36
|
*/
|
|
37
37
|
redirectURL?: string;
|
|
38
38
|
}
|
|
39
|
-
export declare function defineOAuthCognitoEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthCognitoConfig>): import("
|
|
39
|
+
export declare function defineOAuthCognitoEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthCognitoConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
1
3
|
import { defu } from "defu";
|
|
2
|
-
import { eventHandler, getQuery, sendRedirect } from "h3";
|
|
3
4
|
import { discovery } from "openid-client";
|
|
4
5
|
import { withQuery } from "ufo";
|
|
5
6
|
import { getOAuthRedirectURL, handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, handleState, requestAccessToken } from "../utils.js";
|
|
6
|
-
import { useRuntimeConfig } from "#imports";
|
|
7
7
|
export function defineOAuthCognitoEventHandler({ config, onSuccess, onError }) {
|
|
8
|
-
return
|
|
9
|
-
config = defu(config, useRuntimeConfig(
|
|
8
|
+
return defineEventHandler(async (event) => {
|
|
9
|
+
config = defu(config, useRuntimeConfig().oauth?.cognito, {
|
|
10
10
|
authorizationParams: {}
|
|
11
11
|
});
|
|
12
12
|
if (!config.clientId || !config.clientSecret || !config.userPoolId || !config.region) {
|
|
@@ -50,4 +50,4 @@ export interface OAuthDiscordConfig {
|
|
|
50
50
|
*/
|
|
51
51
|
redirectURL?: string;
|
|
52
52
|
}
|
|
53
|
-
export declare function defineOAuthDiscordEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthDiscordConfig>): import("
|
|
53
|
+
export declare function defineOAuthDiscordEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthDiscordConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthDiscordEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.discord, {
|
|
9
9
|
authorizationURL: "https://discord.com/oauth2/authorize",
|
|
10
10
|
tokenURL: "https://discord.com/api/oauth2/token",
|
|
11
11
|
profileRequired: true,
|
|
@@ -44,4 +44,4 @@ export interface OAuthDropboxConfig {
|
|
|
44
44
|
*/
|
|
45
45
|
redirectURL?: string;
|
|
46
46
|
}
|
|
47
|
-
export declare function defineOAuthDropboxEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthDropboxConfig>): import("
|
|
47
|
+
export declare function defineOAuthDropboxEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthDropboxConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
6
6
|
export function defineOAuthDropboxEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.dropbox, {
|
|
9
9
|
authorizationURL: "https://www.dropbox.com/oauth2/authorize",
|
|
10
10
|
tokenURL: "https://api.dropboxapi.com/oauth2/token",
|
|
11
11
|
authorizationParams: {}
|
|
@@ -62,7 +62,7 @@ export function defineOAuthDropboxEventHandler({ config, onSuccess, onError }) {
|
|
|
62
62
|
const user = users;
|
|
63
63
|
if (!user) {
|
|
64
64
|
const error = createError({
|
|
65
|
-
|
|
65
|
+
status: 500,
|
|
66
66
|
message: "Could not get Dropbox user",
|
|
67
67
|
data: tokens
|
|
68
68
|
});
|
|
@@ -56,4 +56,4 @@ export interface OAuthFacebookConfig {
|
|
|
56
56
|
*/
|
|
57
57
|
redirectURL?: string;
|
|
58
58
|
}
|
|
59
|
-
export declare function defineOAuthFacebookEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthFacebookConfig>): import("
|
|
59
|
+
export declare function defineOAuthFacebookEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthFacebookConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { subtle } from "uncrypto";
|
|
5
6
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
6
|
-
import { useRuntimeConfig } from "#imports";
|
|
7
7
|
export function defineOAuthFacebookEventHandler({
|
|
8
8
|
config,
|
|
9
9
|
onSuccess,
|
|
10
10
|
onError
|
|
11
11
|
}) {
|
|
12
|
-
return
|
|
13
|
-
const apiVersion = config?.apiVersion || useRuntimeConfig(
|
|
14
|
-
config = defu(config, useRuntimeConfig(
|
|
12
|
+
return defineEventHandler(async (event) => {
|
|
13
|
+
const apiVersion = config?.apiVersion || useRuntimeConfig().oauth?.facebook?.apiVersion || "v25.0";
|
|
14
|
+
config = defu(config, useRuntimeConfig().oauth?.facebook, {
|
|
15
15
|
apiVersion,
|
|
16
16
|
authorizationURL: `https://www.facebook.com/${apiVersion}/dialog/oauth`,
|
|
17
17
|
tokenURL: `https://graph.facebook.com/${apiVersion}/oauth/access_token`,
|
|
@@ -21,7 +21,7 @@ export function defineOAuthFacebookEventHandler({
|
|
|
21
21
|
const query = getQuery(event);
|
|
22
22
|
if (query.error) {
|
|
23
23
|
const error = createError({
|
|
24
|
-
|
|
24
|
+
status: 401,
|
|
25
25
|
message: `Facebook login failed: ${query.error || "Unknown error"}`,
|
|
26
26
|
data: query
|
|
27
27
|
});
|
|
@@ -77,7 +77,7 @@ export function defineOAuthFacebookEventHandler({
|
|
|
77
77
|
);
|
|
78
78
|
if (!user) {
|
|
79
79
|
const error = createError({
|
|
80
|
-
|
|
80
|
+
status: 500,
|
|
81
81
|
message: "Could not get Facebook user",
|
|
82
82
|
data: tokens
|
|
83
83
|
});
|
|
@@ -48,4 +48,4 @@ export interface OAuthGiteaConfig {
|
|
|
48
48
|
*/
|
|
49
49
|
baseURL?: string;
|
|
50
50
|
}
|
|
51
|
-
export declare function defineOAuthGiteaEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGiteaConfig>): import("
|
|
51
|
+
export declare function defineOAuthGiteaEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGiteaConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import {
|
|
@@ -9,14 +10,13 @@ import {
|
|
|
9
10
|
handleState,
|
|
10
11
|
requestAccessToken
|
|
11
12
|
} from "../utils.js";
|
|
12
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
13
13
|
export function defineOAuthGiteaEventHandler({
|
|
14
14
|
config,
|
|
15
15
|
onSuccess,
|
|
16
16
|
onError
|
|
17
17
|
}) {
|
|
18
|
-
return
|
|
19
|
-
const runtimeConfig = useRuntimeConfig(
|
|
18
|
+
return defineEventHandler(async (event) => {
|
|
19
|
+
const runtimeConfig = useRuntimeConfig().oauth?.gitea;
|
|
20
20
|
const baseURL = config?.baseURL ?? runtimeConfig.baseURL ?? "https://gitea.com";
|
|
21
21
|
config = defu(config, runtimeConfig, {
|
|
22
22
|
authorizationURL: `${baseURL}/login/oauth/authorize`,
|
|
@@ -26,7 +26,7 @@ export function defineOAuthGiteaEventHandler({
|
|
|
26
26
|
const query = getQuery(event);
|
|
27
27
|
if (query.error) {
|
|
28
28
|
const error = createError({
|
|
29
|
-
|
|
29
|
+
status: 401,
|
|
30
30
|
message: `Gitea login failed: ${query.error || "Unknown error"}`,
|
|
31
31
|
data: query
|
|
32
32
|
});
|
|
@@ -93,5 +93,5 @@ interface GitHubTokens {
|
|
|
93
93
|
export declare function defineOAuthGitHubEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthGitHubConfig, {
|
|
94
94
|
user: GitHubUser;
|
|
95
95
|
tokens: GitHubTokens;
|
|
96
|
-
}>): import("
|
|
96
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
97
97
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { getOAuthRedirectURL, handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthGitHubEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.github, {
|
|
9
9
|
authorizationURL: "https://github.com/login/oauth/authorize",
|
|
10
10
|
tokenURL: "https://github.com/login/oauth/access_token",
|
|
11
11
|
apiURL: "https://api.github.com",
|
|
@@ -14,7 +14,7 @@ export function defineOAuthGitHubEventHandler({ config, onSuccess, onError }) {
|
|
|
14
14
|
const query = getQuery(event);
|
|
15
15
|
if (query.error) {
|
|
16
16
|
const error = createError({
|
|
17
|
-
|
|
17
|
+
status: 401,
|
|
18
18
|
message: `GitHub login failed: ${query.error || "Unknown error"}`,
|
|
19
19
|
data: query
|
|
20
20
|
});
|
|
@@ -74,7 +74,7 @@ export function defineOAuthGitHubEventHandler({ config, onSuccess, onError }) {
|
|
|
74
74
|
const primaryEmail = emails.find((email) => email.primary);
|
|
75
75
|
if (!primaryEmail) {
|
|
76
76
|
const error = createError({
|
|
77
|
-
|
|
77
|
+
status: 500,
|
|
78
78
|
message: "Could not get GitHub user email",
|
|
79
79
|
data: tokens
|
|
80
80
|
});
|
|
@@ -49,4 +49,4 @@ export interface OAuthGitLabConfig {
|
|
|
49
49
|
*/
|
|
50
50
|
baseURL?: string;
|
|
51
51
|
}
|
|
52
|
-
export declare function defineOAuthGitLabEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGitLabConfig>): import("
|
|
52
|
+
export declare function defineOAuthGitLabEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGitLabConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import {
|
|
@@ -9,14 +10,13 @@ import {
|
|
|
9
10
|
handleState,
|
|
10
11
|
requestAccessToken
|
|
11
12
|
} from "../utils.js";
|
|
12
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
13
13
|
export function defineOAuthGitLabEventHandler({
|
|
14
14
|
config,
|
|
15
15
|
onSuccess,
|
|
16
16
|
onError
|
|
17
17
|
}) {
|
|
18
|
-
return
|
|
19
|
-
const runtimeConfig = useRuntimeConfig(
|
|
18
|
+
return defineEventHandler(async (event) => {
|
|
19
|
+
const runtimeConfig = useRuntimeConfig().oauth?.gitlab;
|
|
20
20
|
const baseURL = config?.baseURL ?? runtimeConfig.baseURL ?? "https://gitlab.com";
|
|
21
21
|
config = defu(config, runtimeConfig, {
|
|
22
22
|
authorizationURL: `${baseURL}/oauth/authorize`,
|
|
@@ -26,7 +26,7 @@ export function defineOAuthGitLabEventHandler({
|
|
|
26
26
|
const query = getQuery(event);
|
|
27
27
|
if (query.error) {
|
|
28
28
|
const error = createError({
|
|
29
|
-
|
|
29
|
+
status: 401,
|
|
30
30
|
message: `GitLab login failed: ${query.error || "Unknown error"}`,
|
|
31
31
|
data: query
|
|
32
32
|
});
|
|
@@ -44,4 +44,4 @@ export interface OAuthGoogleConfig {
|
|
|
44
44
|
*/
|
|
45
45
|
redirectURL?: string;
|
|
46
46
|
}
|
|
47
|
-
export declare function defineOAuthGoogleEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGoogleConfig>): import("
|
|
47
|
+
export declare function defineOAuthGoogleEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGoogleConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthGoogleEventHandler({
|
|
7
7
|
config,
|
|
8
8
|
onSuccess,
|
|
9
9
|
onError
|
|
10
10
|
}) {
|
|
11
|
-
return
|
|
12
|
-
config = defu(config, useRuntimeConfig(
|
|
11
|
+
return defineEventHandler(async (event) => {
|
|
12
|
+
config = defu(config, useRuntimeConfig().oauth?.google, {
|
|
13
13
|
authorizationURL: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
14
14
|
tokenURL: "https://oauth2.googleapis.com/token",
|
|
15
15
|
userURL: "https://www.googleapis.com/oauth2/v3/userinfo",
|
|
@@ -38,4 +38,4 @@ export interface OAuthHerokuConfig {
|
|
|
38
38
|
*/
|
|
39
39
|
redirectURL?: string;
|
|
40
40
|
}
|
|
41
|
-
export declare function defineOAuthHerokuEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthHerokuConfig>): import("
|
|
41
|
+
export declare function defineOAuthHerokuEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthHerokuConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, requestAccessToken, handleState, handleInvalidState } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
6
6
|
export function defineOAuthHerokuEventHandler({
|
|
7
7
|
config,
|
|
8
8
|
onSuccess,
|
|
9
9
|
onError
|
|
10
10
|
}) {
|
|
11
|
-
return
|
|
12
|
-
const runtimeConfig = useRuntimeConfig(
|
|
11
|
+
return defineEventHandler(async (event) => {
|
|
12
|
+
const runtimeConfig = useRuntimeConfig().oauth?.heroku;
|
|
13
13
|
const baseURL = "https://id.heroku.com";
|
|
14
14
|
config = defu(config, runtimeConfig, {
|
|
15
15
|
authorizationURL: `${baseURL}/oauth/authorize`,
|
|
@@ -19,7 +19,7 @@ export function defineOAuthHerokuEventHandler({
|
|
|
19
19
|
const query = getQuery(event);
|
|
20
20
|
if (query.error) {
|
|
21
21
|
const error = createError({
|
|
22
|
-
|
|
22
|
+
status: 401,
|
|
23
23
|
message: `Heroku login failed: ${query.error || "Unknown error"}`,
|
|
24
24
|
data: query
|
|
25
25
|
});
|
|
@@ -23,4 +23,4 @@ export interface OAuthHubspotConfig {
|
|
|
23
23
|
*/
|
|
24
24
|
scope?: string[];
|
|
25
25
|
}
|
|
26
|
-
export declare function defineOAuthHubspotEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthHubspotConfig>): import("
|
|
26
|
+
export declare function defineOAuthHubspotEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthHubspotConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import defu from "defu";
|
|
4
5
|
import {
|
|
@@ -9,10 +10,9 @@ import {
|
|
|
9
10
|
handleState,
|
|
10
11
|
requestAccessToken
|
|
11
12
|
} from "../utils.js";
|
|
12
|
-
import { useRuntimeConfig } from "#imports";
|
|
13
13
|
export function defineOAuthHubspotEventHandler({ config, onSuccess, onError }) {
|
|
14
|
-
return
|
|
15
|
-
config = defu(config, useRuntimeConfig(
|
|
14
|
+
return defineEventHandler(async (event) => {
|
|
15
|
+
config = defu(config, useRuntimeConfig().oauth?.hubspot);
|
|
16
16
|
if (!config.clientId || !config.clientSecret || !config.redirectURL) {
|
|
17
17
|
return handleMissingConfiguration(event, "hubspot", ["clientId", "clientSecret", "redirectURL"], onError);
|
|
18
18
|
}
|
|
@@ -45,4 +45,4 @@ export interface OAuthInstagramConfig {
|
|
|
45
45
|
*/
|
|
46
46
|
redirectURL?: string;
|
|
47
47
|
}
|
|
48
|
-
export declare function defineOAuthInstagramEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthInstagramConfig>): import("
|
|
48
|
+
export declare function defineOAuthInstagramEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthInstagramConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthInstagramEventHandler({
|
|
7
7
|
config,
|
|
8
8
|
onSuccess,
|
|
9
9
|
onError
|
|
10
10
|
}) {
|
|
11
|
-
return
|
|
12
|
-
config = defu(config, useRuntimeConfig(
|
|
11
|
+
return defineEventHandler(async (event) => {
|
|
12
|
+
config = defu(config, useRuntimeConfig().oauth?.instagram, {
|
|
13
13
|
scope: ["business_basic"],
|
|
14
14
|
authorizationURL: "https://www.instagram.com/oauth/authorize",
|
|
15
15
|
tokenURL: "https://api.instagram.com/oauth/access_token",
|
|
@@ -18,7 +18,7 @@ export function defineOAuthInstagramEventHandler({
|
|
|
18
18
|
const query = getQuery(event);
|
|
19
19
|
if (query.error) {
|
|
20
20
|
const error = createError({
|
|
21
|
-
|
|
21
|
+
status: 401,
|
|
22
22
|
message: `Instagram login failed: ${query.error || "Unknown error"}`,
|
|
23
23
|
data: {
|
|
24
24
|
error: query.error,
|
|
@@ -70,7 +70,7 @@ export function defineOAuthInstagramEventHandler({
|
|
|
70
70
|
);
|
|
71
71
|
if (!user) {
|
|
72
72
|
const error = createError({
|
|
73
|
-
|
|
73
|
+
status: 500,
|
|
74
74
|
message: "Could not get Instagram user",
|
|
75
75
|
data: tokens
|
|
76
76
|
});
|
|
@@ -45,4 +45,4 @@ export interface OAuthKeycloakConfig {
|
|
|
45
45
|
*/
|
|
46
46
|
redirectURL?: string;
|
|
47
47
|
}
|
|
48
|
-
export declare function defineOAuthKeycloakEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthKeycloakConfig>): import("
|
|
48
|
+
export declare function defineOAuthKeycloakEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthKeycloakConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
6
6
|
export function defineOAuthKeycloakEventHandler({
|
|
7
7
|
config,
|
|
8
8
|
onSuccess,
|
|
9
9
|
onError
|
|
10
10
|
}) {
|
|
11
|
-
return
|
|
12
|
-
config = defu(config, useRuntimeConfig(
|
|
11
|
+
return defineEventHandler(async (event) => {
|
|
12
|
+
config = defu(config, useRuntimeConfig().oauth?.keycloak, {
|
|
13
13
|
authorizationParams: {}
|
|
14
14
|
});
|
|
15
15
|
const query = getQuery(event);
|
|
16
16
|
if (query.error) {
|
|
17
17
|
const error = createError({
|
|
18
|
-
|
|
18
|
+
status: 401,
|
|
19
19
|
message: `Keycloak login failed: ${query.error || "Unknown error"}`,
|
|
20
20
|
data: query
|
|
21
21
|
});
|
|
@@ -79,7 +79,7 @@ export function defineOAuthKeycloakEventHandler({
|
|
|
79
79
|
);
|
|
80
80
|
if (!user) {
|
|
81
81
|
const error = createError({
|
|
82
|
-
|
|
82
|
+
status: 500,
|
|
83
83
|
message: "Could not get Keycloak user",
|
|
84
84
|
data: tokens
|
|
85
85
|
});
|
|
@@ -51,5 +51,5 @@ interface KickTokens {
|
|
|
51
51
|
export declare function defineOAuthKickEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthKickConfig, {
|
|
52
52
|
user: KickUser;
|
|
53
53
|
tokens: KickTokens;
|
|
54
|
-
}>): import("
|
|
54
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
55
55
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, getOAuthRedirectURL, requestAccessToken, handlePkceVerifier, handleState } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
6
6
|
export function defineOAuthKickEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.kick, {
|
|
9
9
|
authorizationURL: "https://id.kick.com/oauth/authorize",
|
|
10
10
|
tokenURL: "https://id.kick.com/oauth/token"
|
|
11
11
|
});
|
|
@@ -58,7 +58,7 @@ export function defineOAuthKickEventHandler({ config, onSuccess, onError }) {
|
|
|
58
58
|
});
|
|
59
59
|
if (!data || !data.length) {
|
|
60
60
|
const error = createError({
|
|
61
|
-
|
|
61
|
+
status: 500,
|
|
62
62
|
message: "Could not get Kick user",
|
|
63
63
|
data: tokens
|
|
64
64
|
});
|
|
@@ -42,4 +42,4 @@ export interface OAuthLineConfig {
|
|
|
42
42
|
*/
|
|
43
43
|
redirectURL?: string;
|
|
44
44
|
}
|
|
45
|
-
export declare function defineOAuthLineEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthLineConfig>): import("
|
|
45
|
+
export declare function defineOAuthLineEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthLineConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthLineEventHandler({
|
|
7
7
|
config,
|
|
8
8
|
onSuccess,
|
|
9
9
|
onError
|
|
10
10
|
}) {
|
|
11
|
-
return
|
|
12
|
-
config = defu(config, useRuntimeConfig(
|
|
11
|
+
return defineEventHandler(async (event) => {
|
|
12
|
+
config = defu(config, useRuntimeConfig().oauth?.line, {
|
|
13
13
|
authorizationURL: "https://access.line.me/oauth2/v2.1/authorize",
|
|
14
14
|
tokenURL: "https://api.line.me/oauth2/v2.1/token",
|
|
15
15
|
userURL: "https://api.line.me/v2/profile",
|
|
@@ -18,7 +18,7 @@ export function defineOAuthLineEventHandler({
|
|
|
18
18
|
const query = getQuery(event);
|
|
19
19
|
if (query.error) {
|
|
20
20
|
const error = createError({
|
|
21
|
-
|
|
21
|
+
status: 401,
|
|
22
22
|
message: `Line login failed: ${query.error || "Unknown error"}`,
|
|
23
23
|
data: query
|
|
24
24
|
});
|
|
@@ -67,7 +67,7 @@ export function defineOAuthLineEventHandler({
|
|
|
67
67
|
});
|
|
68
68
|
if (!user) {
|
|
69
69
|
const error = createError({
|
|
70
|
-
|
|
70
|
+
status: 500,
|
|
71
71
|
message: "Could not get Line user",
|
|
72
72
|
data: tokens
|
|
73
73
|
});
|