nuxt-auth-utils 0.5.34 → 0.6.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 +118 -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 +6 -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 +10 -11
- 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 +9 -9
- 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/session.d.ts +11 -0
- package/dist/runtime/server/lib/session.js +33 -0
- package/dist/runtime/server/lib/utils.d.ts +9 -8
- package/dist/runtime/server/lib/utils.js +13 -11
- package/dist/runtime/server/lib/webauthn/authenticate.d.ts +1 -1
- package/dist/runtime/server/lib/webauthn/authenticate.js +8 -9
- package/dist/runtime/server/lib/webauthn/register.d.ts +2 -2
- package/dist/runtime/server/lib/webauthn/register.js +10 -11
- 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 +3 -4
- package/dist/runtime/server/utils/password.js +1 -1
- package/dist/runtime/server/utils/session.d.ts +26 -17
- package/dist/runtime/server/utils/session.js +49 -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/session.d.ts +5 -2
- 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
|
@@ -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, handlePkceVerifier } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
6
6
|
export function defineOAuthSalesforceEventHandler({
|
|
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?.salesforce;
|
|
13
13
|
const baseURL = config?.baseURL || runtimeConfig?.baseURL || "https://login.salesforce.com";
|
|
14
14
|
config = defu(config, runtimeConfig, {
|
|
15
15
|
authorizationURL: `${baseURL}/services/oauth2/authorize`,
|
|
@@ -19,7 +19,7 @@ export function defineOAuthSalesforceEventHandler({
|
|
|
19
19
|
const query = getQuery(event);
|
|
20
20
|
if (query.error) {
|
|
21
21
|
const error = createError({
|
|
22
|
-
|
|
22
|
+
status: 401,
|
|
23
23
|
message: `Salesforce login failed: ${query.error || "Unknown error"}`,
|
|
24
24
|
data: query
|
|
25
25
|
});
|
|
@@ -95,4 +95,4 @@ export interface OAuthSeznamUser {
|
|
|
95
95
|
export declare function defineOAuthSeznamEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSeznamConfig, {
|
|
96
96
|
user: OAuthSeznamUser;
|
|
97
97
|
tokens: unknown;
|
|
98
|
-
}>): import("
|
|
98
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
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 { withQuery } from "ufo";
|
|
4
5
|
import { getOAuthRedirectURL, handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthSeznamEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.seznam, {
|
|
9
9
|
authorizationURL: "https://login.szn.cz/api/v1/oauth/auth",
|
|
10
10
|
tokenURL: "https://login.szn.cz/api/v1/oauth/token",
|
|
11
11
|
userURL: "https://login.szn.cz/api/v1/user"
|
|
@@ -23,4 +23,4 @@ export interface OAuthShopifyCustomerConfig {
|
|
|
23
23
|
*/
|
|
24
24
|
redirectURL?: string;
|
|
25
25
|
}
|
|
26
|
-
export declare function defineOAuthShopifyCustomerEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthShopifyCustomerConfig>): import("
|
|
26
|
+
export declare function defineOAuthShopifyCustomerEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthShopifyCustomerConfig>): 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 { getOAuthRedirectURL, handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, handlePkceVerifier, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthShopifyCustomerEventHandler({
|
|
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?.shopifyCustomer, {});
|
|
13
13
|
const query = getQuery(event);
|
|
14
14
|
if (!config.clientId || !config.shopDomain) {
|
|
15
15
|
return handleMissingConfiguration(event, "shopifyCustomer", ["clientId", "shopDomain"], onError);
|
|
@@ -19,7 +19,7 @@ export function defineOAuthShopifyCustomerEventHandler({
|
|
|
19
19
|
const discoveryResponse = await $fetch(`https://${config.shopDomain}/.well-known/openid-configuration`).then((d) => d).catch(() => null);
|
|
20
20
|
if (!discoveryResponse?.issuer) {
|
|
21
21
|
const error = createError({
|
|
22
|
-
|
|
22
|
+
status: 400,
|
|
23
23
|
message: "Getting Shopify discovery endpoint failed."
|
|
24
24
|
});
|
|
25
25
|
if (!onError) throw error;
|
|
@@ -60,7 +60,7 @@ export function defineOAuthShopifyCustomerEventHandler({
|
|
|
60
60
|
const apiDiscoveryUrl = await $fetch(`https://${config.shopDomain}/.well-known/customer-account-api`).then((d) => d).catch(() => null);
|
|
61
61
|
if (!apiDiscoveryUrl?.graphql_api) {
|
|
62
62
|
const error = createError({
|
|
63
|
-
|
|
63
|
+
status: 400,
|
|
64
64
|
message: "Getting Shopify api endpoints failed."
|
|
65
65
|
});
|
|
66
66
|
if (!onError) throw error;
|
|
@@ -79,7 +79,7 @@ export function defineOAuthShopifyCustomerEventHandler({
|
|
|
79
79
|
}).then((d) => d.data).catch(() => null);
|
|
80
80
|
if (!user || !user.customer) {
|
|
81
81
|
const error = createError({
|
|
82
|
-
|
|
82
|
+
status: 400,
|
|
83
83
|
message: "Getting Shopify Customer failed."
|
|
84
84
|
});
|
|
85
85
|
if (!onError) throw error;
|
|
@@ -38,4 +38,4 @@ export interface OAuthSlackConfig {
|
|
|
38
38
|
*/
|
|
39
39
|
redirectURL?: string;
|
|
40
40
|
}
|
|
41
|
-
export declare function defineOAuthSlackEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthSlackConfig>): import("
|
|
41
|
+
export declare function defineOAuthSlackEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthSlackConfig>): 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 defineOAuthSlackEventHandler({
|
|
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?.slack;
|
|
13
13
|
const baseURL = "https://slack.com";
|
|
14
14
|
config = defu(config, runtimeConfig, {
|
|
15
15
|
authorizationURL: `${baseURL}/openid/connect/authorize`,
|
|
@@ -19,7 +19,7 @@ export function defineOAuthSlackEventHandler({
|
|
|
19
19
|
const query = getQuery(event);
|
|
20
20
|
if (query.error) {
|
|
21
21
|
const error = createError({
|
|
22
|
-
|
|
22
|
+
status: 401,
|
|
23
23
|
message: `Slack login failed: ${query.error || "Unknown error"}`,
|
|
24
24
|
data: query
|
|
25
25
|
});
|
|
@@ -90,5 +90,5 @@ interface SpotifyTokens {
|
|
|
90
90
|
export declare function defineOAuthSpotifyEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSpotifyConfig, {
|
|
91
91
|
user: SpotifyUser;
|
|
92
92
|
tokens: SpotifyTokens;
|
|
93
|
-
}>): import("
|
|
93
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
94
94
|
export {};
|
|
@@ -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 defineOAuthSpotifyEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.spotify, {
|
|
9
9
|
authorizationURL: "https://accounts.spotify.com/authorize",
|
|
10
10
|
tokenURL: "https://accounts.spotify.com/api/token",
|
|
11
11
|
authorizationParams: {}
|
|
@@ -17,4 +17,4 @@ export interface OAuthSteamConfig {
|
|
|
17
17
|
*/
|
|
18
18
|
redirectURL?: string;
|
|
19
19
|
}
|
|
20
|
-
export declare function defineOAuthSteamEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSteamConfig>): import("
|
|
20
|
+
export declare function defineOAuthSteamEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSteamConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, createError, getQuery, getRequestURL, 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 { handleInvalidState, handleMissingConfiguration, handleState } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthSteamEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.steam, {
|
|
9
9
|
authorizationURL: "https://steamcommunity.com/openid/login"
|
|
10
10
|
});
|
|
11
11
|
const query = getQuery(event);
|
|
12
12
|
if (!config.apiKey) {
|
|
13
13
|
return handleMissingConfiguration(event, "steam", ["apiKey"], onError);
|
|
14
14
|
}
|
|
15
|
-
const url = getRequestURL(event);
|
|
15
|
+
const url = getRequestURL(event, { xForwardedProto: true });
|
|
16
16
|
const state = await handleState(event, { isCallback: Boolean(query["openid.claimed_id"]) });
|
|
17
17
|
if (!query["openid.claimed_id"]) {
|
|
18
|
-
const redirectURL = withQuery(config.redirectURL ||
|
|
18
|
+
const redirectURL = withQuery(config.redirectURL || url.href, { state });
|
|
19
19
|
const realm = url.port ? `${url.protocol}//${url.hostname}:${url.port}` : `${url.protocol}//${url.hostname}`;
|
|
20
20
|
const steamOpenIdParams = {
|
|
21
21
|
"openid.ns": "http://specs.openid.net/auth/2.0",
|
|
@@ -32,7 +32,7 @@ export function defineOAuthSteamEventHandler({ config, onSuccess, onError }) {
|
|
|
32
32
|
}
|
|
33
33
|
if (!query["openid.signed"] || !query["openid.sig"]) {
|
|
34
34
|
const error = createError({
|
|
35
|
-
|
|
35
|
+
status: 400,
|
|
36
36
|
message: "Steam login failed: Incomplete query."
|
|
37
37
|
});
|
|
38
38
|
if (!onError) throw error;
|
|
@@ -47,7 +47,7 @@ export function defineOAuthSteamEventHandler({ config, onSuccess, onError }) {
|
|
|
47
47
|
for (const signed of query["openid.signed"].split(",")) {
|
|
48
48
|
if (!query[`openid.${signed}`]) {
|
|
49
49
|
const error = createError({
|
|
50
|
-
|
|
50
|
+
status: 400,
|
|
51
51
|
message: "Steam login failed: Incomplete query."
|
|
52
52
|
});
|
|
53
53
|
if (!onError) throw error;
|
|
@@ -60,7 +60,7 @@ export function defineOAuthSteamEventHandler({ config, onSuccess, onError }) {
|
|
|
60
60
|
const valid = validRegex.test(auth_validation);
|
|
61
61
|
if (!valid) {
|
|
62
62
|
const error = createError({
|
|
63
|
-
|
|
63
|
+
status: 401,
|
|
64
64
|
message: "Steam login failed: Claimed identity is invalid."
|
|
65
65
|
});
|
|
66
66
|
if (!onError) throw error;
|
|
@@ -116,4 +116,4 @@ export interface OAuthStravaTokens {
|
|
|
116
116
|
export declare function defineOAuthStravaEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthStravaConfig, {
|
|
117
117
|
user: OAuthStravaUser;
|
|
118
118
|
tokens: OAuthStravaTokens;
|
|
119
|
-
}>): import("
|
|
119
|
+
}>): 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,18 +10,17 @@ import {
|
|
|
9
10
|
handleState,
|
|
10
11
|
requestAccessToken
|
|
11
12
|
} from "../utils.js";
|
|
12
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
13
13
|
export function defineOAuthStravaEventHandler({
|
|
14
14
|
config,
|
|
15
15
|
onSuccess,
|
|
16
16
|
onError
|
|
17
17
|
}) {
|
|
18
|
-
return
|
|
19
|
-
config = defu(config, useRuntimeConfig(
|
|
18
|
+
return defineEventHandler(async (event) => {
|
|
19
|
+
config = defu(config, useRuntimeConfig().oauth?.strava);
|
|
20
20
|
const query = getQuery(event);
|
|
21
21
|
if (query.error) {
|
|
22
22
|
const error = createError({
|
|
23
|
-
|
|
23
|
+
status: 401,
|
|
24
24
|
message: `Strava login failed: ${query.error || "Unknown error"}`,
|
|
25
25
|
data: query
|
|
26
26
|
});
|
|
@@ -42,4 +42,4 @@ export interface OAuthTikTokConfig {
|
|
|
42
42
|
*/
|
|
43
43
|
redirectURL?: string;
|
|
44
44
|
}
|
|
45
|
-
export declare function defineOAuthTikTokEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthTikTokConfig>): import("
|
|
45
|
+
export declare function defineOAuthTikTokEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthTikTokConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
1
3
|
import crypto from "node:crypto";
|
|
2
|
-
import { eventHandler, getQuery, sendRedirect } from "h3";
|
|
3
4
|
import { withQuery } from "ufo";
|
|
4
5
|
import { defu } from "defu";
|
|
5
6
|
import { handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, getOAuthRedirectURL, handleState, requestAccessToken } from "../utils.js";
|
|
6
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
7
7
|
export function defineOAuthTikTokEventHandler({ config, onSuccess, onError }) {
|
|
8
|
-
return
|
|
9
|
-
config = defu(config, useRuntimeConfig(
|
|
8
|
+
return defineEventHandler(async (event) => {
|
|
9
|
+
config = defu(config, useRuntimeConfig().oauth?.tiktok, {
|
|
10
10
|
sandbox: import.meta.dev,
|
|
11
11
|
authorizationURL: "https://www.tiktok.com/v2/auth/authorize/",
|
|
12
12
|
tokenURL: "https://open.tiktokapis.com/v2/oauth/token/"
|
|
@@ -74,7 +74,7 @@ export function defineOAuthTikTokEventHandler({ config, onSuccess, onError }) {
|
|
|
74
74
|
const user = userInfo?.data?.user;
|
|
75
75
|
if (!user) {
|
|
76
76
|
const error = createError({
|
|
77
|
-
|
|
77
|
+
status: 500,
|
|
78
78
|
message: "Could not get TikTok user",
|
|
79
79
|
data: tokens
|
|
80
80
|
});
|
|
@@ -67,5 +67,5 @@ interface TwitchTokens {
|
|
|
67
67
|
export declare function defineOAuthTwitchEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthTwitchConfig, {
|
|
68
68
|
user: TwitchUser;
|
|
69
69
|
tokens: TwitchTokens;
|
|
70
|
-
}>): import("
|
|
70
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
71
71
|
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 { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
6
6
|
export function defineOAuthTwitchEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.twitch, {
|
|
9
9
|
authorizationURL: "https://id.twitch.tv/oauth2/authorize",
|
|
10
10
|
tokenURL: "https://id.twitch.tv/oauth2/token",
|
|
11
11
|
authorizationParams: {}
|
|
@@ -58,7 +58,7 @@ export function defineOAuthTwitchEventHandler({ config, onSuccess, onError }) {
|
|
|
58
58
|
const user = users.data?.[0];
|
|
59
59
|
if (!user) {
|
|
60
60
|
const error = createError({
|
|
61
|
-
|
|
61
|
+
status: 500,
|
|
62
62
|
message: "Could not get Twitch user",
|
|
63
63
|
data: tokens
|
|
64
64
|
});
|
|
@@ -43,4 +43,4 @@ export interface OAuthVKConfig {
|
|
|
43
43
|
*/
|
|
44
44
|
redirectURL?: string;
|
|
45
45
|
}
|
|
46
|
-
export declare function defineOAuthVKEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthVKConfig>): import("
|
|
46
|
+
export declare function defineOAuthVKEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthVKConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
1
3
|
import crypto from "node:crypto";
|
|
2
|
-
import { eventHandler, getQuery, sendRedirect } from "h3";
|
|
3
4
|
import { withQuery } from "ufo";
|
|
4
5
|
import { defu } from "defu";
|
|
5
6
|
import {
|
|
@@ -10,14 +11,13 @@ import {
|
|
|
10
11
|
handleState,
|
|
11
12
|
requestAccessToken
|
|
12
13
|
} from "../utils.js";
|
|
13
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
14
14
|
export function defineOAuthVKEventHandler({
|
|
15
15
|
config,
|
|
16
16
|
onSuccess,
|
|
17
17
|
onError
|
|
18
18
|
}) {
|
|
19
|
-
return
|
|
20
|
-
config = defu(config, useRuntimeConfig(
|
|
19
|
+
return defineEventHandler(async (event) => {
|
|
20
|
+
config = defu(config, useRuntimeConfig().oauth?.vk, {
|
|
21
21
|
authorizationURL: "https://id.vk.com/authorize",
|
|
22
22
|
tokenURL: "https://id.vk.com/oauth2/auth",
|
|
23
23
|
userURL: "https://id.vk.com/oauth2/user_info"
|
|
@@ -78,7 +78,7 @@ export function defineOAuthVKEventHandler({
|
|
|
78
78
|
});
|
|
79
79
|
if (!user) {
|
|
80
80
|
const error = createError({
|
|
81
|
-
|
|
81
|
+
status: 500,
|
|
82
82
|
message: "Could not get VK user",
|
|
83
83
|
data: tokens
|
|
84
84
|
});
|
|
@@ -64,4 +64,4 @@ export interface WechatOAuthUser {
|
|
|
64
64
|
export declare function defineOAuthWechatEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthWechatConfig, {
|
|
65
65
|
user: WechatOAuthUser;
|
|
66
66
|
tokens: WechatOAuthTokens;
|
|
67
|
-
}>): import("
|
|
67
|
+
}>): 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 {
|
|
@@ -7,7 +8,6 @@ import {
|
|
|
7
8
|
handleMissingConfiguration,
|
|
8
9
|
handleState
|
|
9
10
|
} from "../utils.js";
|
|
10
|
-
import { createError, useRuntimeConfig } from "#imports";
|
|
11
11
|
function isWechatOAuthError(value) {
|
|
12
12
|
return Boolean(
|
|
13
13
|
value && typeof value === "object" && "errcode" in value && "errmsg" in value
|
|
@@ -15,7 +15,7 @@ function isWechatOAuthError(value) {
|
|
|
15
15
|
}
|
|
16
16
|
function handleWechatOAuthError(event, phase, oauthError, onError) {
|
|
17
17
|
const error = createError({
|
|
18
|
-
|
|
18
|
+
status: 401,
|
|
19
19
|
message: `WeChat ${phase} request failed: ${oauthError.errmsg} (${oauthError.errcode})`,
|
|
20
20
|
data: oauthError
|
|
21
21
|
});
|
|
@@ -27,8 +27,8 @@ export function defineOAuthWechatEventHandler({
|
|
|
27
27
|
onSuccess,
|
|
28
28
|
onError
|
|
29
29
|
}) {
|
|
30
|
-
return
|
|
31
|
-
config = defu(config, useRuntimeConfig(
|
|
30
|
+
return defineEventHandler(async (event) => {
|
|
31
|
+
config = defu(config, useRuntimeConfig().oauth?.wechat, {
|
|
32
32
|
authorizationURL: "https://open.weixin.qq.com/connect/qrconnect",
|
|
33
33
|
tokenURL: "https://api.weixin.qq.com/sns/oauth2/access_token",
|
|
34
34
|
userURL: "https://api.weixin.qq.com/sns/userinfo",
|
|
@@ -37,7 +37,7 @@ export function defineOAuthWechatEventHandler({
|
|
|
37
37
|
const query = getQuery(event);
|
|
38
38
|
if (query.error) {
|
|
39
39
|
const error = createError({
|
|
40
|
-
|
|
40
|
+
status: 401,
|
|
41
41
|
message: `WeChat login failed: ${query.error || "Unknown error"}`,
|
|
42
42
|
data: query
|
|
43
43
|
});
|
|
@@ -51,7 +51,7 @@ export function defineOAuthWechatEventHandler({
|
|
|
51
51
|
if (!query.code && query.state) {
|
|
52
52
|
await handleState(event, { isCallback: true });
|
|
53
53
|
const error = createError({
|
|
54
|
-
|
|
54
|
+
status: 401,
|
|
55
55
|
message: "WeChat login failed: authorization denied",
|
|
56
56
|
data: query
|
|
57
57
|
});
|
|
@@ -63,4 +63,4 @@ export interface OAuthWorkOSTokens {
|
|
|
63
63
|
export declare function defineOAuthWorkOSEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthWorkOSConfig, {
|
|
64
64
|
user: OAuthWorkOSUser;
|
|
65
65
|
tokens: OAuthWorkOSTokens;
|
|
66
|
-
}>): import("
|
|
66
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEventHandler, getQuery, getRequestHeader, getRequestIP, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
2
|
import { withQuery } from "ufo";
|
|
3
3
|
import { defu } from "defu";
|
|
4
4
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, handleInvalidState, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
5
|
export function defineOAuthWorkOSEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
6
|
+
return defineEventHandler(async (event) => {
|
|
7
|
+
config = defu(config, useRuntimeConfig().oauth?.workos, { screen_hint: "sign-in" });
|
|
9
8
|
if (!config.clientId || !config.clientSecret) {
|
|
10
9
|
return handleMissingConfiguration(event, "workos", ["clientId", "clientSecret"], onError);
|
|
11
10
|
}
|
|
@@ -43,4 +43,4 @@ export interface OAuthXConfig {
|
|
|
43
43
|
*/
|
|
44
44
|
redirectURL?: string;
|
|
45
45
|
}
|
|
46
|
-
export declare function defineOAuthXEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthXConfig>): import("
|
|
46
|
+
export declare function defineOAuthXEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthXConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "
|
|
1
|
+
import { defineEventHandler, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { defu } from "defu";
|
|
3
|
-
import { eventHandler, getQuery, sendRedirect } from "h3";
|
|
4
4
|
import { withQuery } from "ufo";
|
|
5
5
|
import {
|
|
6
6
|
getOAuthRedirectURL,
|
|
@@ -16,8 +16,8 @@ export function defineOAuthXEventHandler({
|
|
|
16
16
|
onSuccess,
|
|
17
17
|
onError
|
|
18
18
|
}) {
|
|
19
|
-
return
|
|
20
|
-
config = defu(config, useRuntimeConfig(
|
|
19
|
+
return defineEventHandler(async (event) => {
|
|
20
|
+
config = defu(config, useRuntimeConfig().oauth?.x, {
|
|
21
21
|
authorizationURL: "https://x.com/i/oauth2/authorize",
|
|
22
22
|
tokenURL: "https://api.x.com/2/oauth2/token",
|
|
23
23
|
userURL: "https://api.x.com/2/users/me",
|
|
@@ -28,4 +28,4 @@ export interface OAuthXSUAAConfig {
|
|
|
28
28
|
*/
|
|
29
29
|
redirectURL?: string;
|
|
30
30
|
}
|
|
31
|
-
export declare function defineOAuthXSUAAEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthXSUAAConfig>): import("
|
|
31
|
+
export declare function defineOAuthXSUAAEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthXSUAAConfig>): 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 defineOAuthXSUAAEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.xsuaa);
|
|
9
9
|
const query = getQuery(event);
|
|
10
10
|
if (!config.clientId || !config.clientSecret || !config.domain) {
|
|
11
11
|
return handleMissingConfiguration(event, "xsuaa", ["clientId", "clientSecret", "domain"], onError);
|
|
@@ -43,4 +43,4 @@ export interface OAuthYandexConfig {
|
|
|
43
43
|
*/
|
|
44
44
|
redirectURL?: string;
|
|
45
45
|
}
|
|
46
|
-
export declare function defineOAuthYandexEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthYandexConfig>): import("
|
|
46
|
+
export declare function defineOAuthYandexEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthYandexConfig>): 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,14 +10,13 @@ import {
|
|
|
9
10
|
handleState,
|
|
10
11
|
requestAccessToken
|
|
11
12
|
} from "../utils.js";
|
|
12
|
-
import { useRuntimeConfig } from "#imports";
|
|
13
13
|
export function defineOAuthYandexEventHandler({
|
|
14
14
|
config,
|
|
15
15
|
onSuccess,
|
|
16
16
|
onError
|
|
17
17
|
}) {
|
|
18
|
-
return
|
|
19
|
-
config = defu(config, useRuntimeConfig(
|
|
18
|
+
return defineEventHandler(async (event) => {
|
|
19
|
+
config = defu(config, useRuntimeConfig().oauth?.yandex, {
|
|
20
20
|
authorizationURL: "https://oauth.yandex.ru/authorize",
|
|
21
21
|
tokenURL: "https://oauth.yandex.ru/token",
|
|
22
22
|
userURL: "https://login.yandex.ru/info"
|
|
@@ -107,4 +107,4 @@ export interface ZendeskTokens {
|
|
|
107
107
|
export declare function defineOAuthZendeskEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthZendeskConfig, {
|
|
108
108
|
user: ZendeskUser;
|
|
109
109
|
tokens: ZendeskTokens;
|
|
110
|
-
}>): import("
|
|
110
|
+
}>): 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,7 +10,6 @@ import {
|
|
|
9
10
|
handleState,
|
|
10
11
|
requestAccessToken
|
|
11
12
|
} from "../utils.js";
|
|
12
|
-
import { useRuntimeConfig } from "#imports";
|
|
13
13
|
function getMarketplaceHeaders(config) {
|
|
14
14
|
const headers = {};
|
|
15
15
|
if (config.marketplaceName) {
|
|
@@ -31,8 +31,8 @@ export function defineOAuthZendeskEventHandler({
|
|
|
31
31
|
onSuccess,
|
|
32
32
|
onError
|
|
33
33
|
}) {
|
|
34
|
-
return
|
|
35
|
-
const runtimeConfig = useRuntimeConfig(
|
|
34
|
+
return defineEventHandler(async (event) => {
|
|
35
|
+
const runtimeConfig = useRuntimeConfig().oauth?.zendesk;
|
|
36
36
|
config = defu(config, runtimeConfig);
|
|
37
37
|
config.scope = config.scope?.length ? config.scope : ["read"];
|
|
38
38
|
if (!config.scope.includes("read") && !config.scope.includes("users:read")) {
|
|
@@ -34,4 +34,4 @@ export interface OAuthZitadelConfig {
|
|
|
34
34
|
*/
|
|
35
35
|
redirectURL?: string;
|
|
36
36
|
}
|
|
37
|
-
export declare function defineOAuthZitadelEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthZitadelConfig>): import("
|
|
37
|
+
export declare function defineOAuthZitadelEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthZitadelConfig>): 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 { hasProtocol, withQuery } from "ufo";
|
|
3
4
|
import { defu } from "defu";
|
|
4
5
|
import { handleMissingConfiguration, handleAccessTokenErrorResponse, getOAuthRedirectURL, requestAccessToken, handleState, handlePkceVerifier, handleInvalidState } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
6
6
|
export function defineOAuthZitadelEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.zitadel, {
|
|
9
9
|
authorizationParams: {}
|
|
10
10
|
});
|
|
11
11
|
const query = getQuery(event);
|
|
12
12
|
if (query.error) {
|
|
13
13
|
const error = createError({
|
|
14
|
-
|
|
14
|
+
status: 401,
|
|
15
15
|
message: `Zitadel login failed: ${query.error || "Unknown error"}`,
|
|
16
16
|
data: query
|
|
17
17
|
});
|
|
@@ -75,7 +75,7 @@ export function defineOAuthZitadelEventHandler({ config, onSuccess, onError }) {
|
|
|
75
75
|
});
|
|
76
76
|
if (!user) {
|
|
77
77
|
const error = createError({
|
|
78
|
-
|
|
78
|
+
status: 500,
|
|
79
79
|
message: "Could not get Zitadel user",
|
|
80
80
|
data: tokens
|
|
81
81
|
});
|