nuxt-auth-utils 0.5.33 → 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 +91 -16
- package/dist/module.d.mts +3 -3
- package/dist/module.json +5 -2
- package/dist/module.mjs +28 -31
- package/dist/runtime/app/components/AuthState.d.vue.ts +20 -0
- 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 +9 -9
- 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 +49 -2
- 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 +110 -0
- package/dist/runtime/server/lib/oauth/zendesk.js +109 -0
- 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 +4 -4
- package/dist/runtime/types/webauthn.d.ts +14 -15
- package/package.json +12 -9
- 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,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
|
});
|
|
@@ -38,4 +38,4 @@ export interface OAuthLinearConfig {
|
|
|
38
38
|
*/
|
|
39
39
|
redirectURL?: string;
|
|
40
40
|
}
|
|
41
|
-
export declare function defineOAuthLinearEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthLinearConfig>): import("
|
|
41
|
+
export declare function defineOAuthLinearEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthLinearConfig>): 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 defineOAuthLinearEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.linear, {
|
|
9
9
|
authorizationURL: "https://linear.app/oauth/authorize",
|
|
10
10
|
tokenURL: "https://api.linear.app/oauth/token",
|
|
11
11
|
authorizationParams: {}
|
|
@@ -13,7 +13,7 @@ export function defineOAuthLinearEventHandler({ 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: `Linear login failed: ${query.error || "Unknown error"}`,
|
|
18
18
|
data: query
|
|
19
19
|
});
|
|
@@ -70,7 +70,7 @@ export function defineOAuthLinearEventHandler({ config, onSuccess, onError }) {
|
|
|
70
70
|
});
|
|
71
71
|
if (!user.data || !user.data.viewer) {
|
|
72
72
|
const error = createError({
|
|
73
|
-
|
|
73
|
+
status: 500,
|
|
74
74
|
message: "Could not get Linear user",
|
|
75
75
|
data: tokens
|
|
76
76
|
});
|
|
@@ -42,4 +42,4 @@ export interface OAuthLinkedInConfig {
|
|
|
42
42
|
*/
|
|
43
43
|
redirectURL?: string;
|
|
44
44
|
}
|
|
45
|
-
export declare function defineOAuthLinkedInEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthLinkedInConfig>): import("
|
|
45
|
+
export declare function defineOAuthLinkedInEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthLinkedInConfig>): 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 defineOAuthLinkedInEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.linkedin, {
|
|
9
9
|
authorizationURL: "https://www.linkedin.com/oauth/v2/authorization",
|
|
10
10
|
tokenURL: "https://www.linkedin.com/oauth/v2/accessToken",
|
|
11
11
|
authorizationParams: {}
|
|
@@ -70,4 +70,4 @@ export interface LiveChatConfig {
|
|
|
70
70
|
*/
|
|
71
71
|
authorizationParams?: Record<string, string>;
|
|
72
72
|
}
|
|
73
|
-
export declare function defineOAuthLiveChatEventHandler({ config, onSuccess, onError, }: OAuthConfig<LiveChatConfig>): import("
|
|
73
|
+
export declare function defineOAuthLiveChatEventHandler({ config, onSuccess, onError, }: OAuthConfig<LiveChatConfig>): 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 { defu } from "defu";
|
|
3
4
|
import { withQuery } from "ufo";
|
|
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 defineOAuthLiveChatEventHandler({
|
|
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?.livechat, {
|
|
20
20
|
authorizationURL: "https://accounts.livechat.com",
|
|
21
21
|
tokenURL: "https://accounts.livechat.com/v2/token",
|
|
22
22
|
userURL: "https://accounts.livechat.com/v2/accounts/me",
|
|
@@ -58,5 +58,5 @@ interface MastodonTokens {
|
|
|
58
58
|
export declare function defineOAuthMastodonEventHandler<TUser = OAuthMastodonUser>({ config: userConfig, onSuccess, onError }: OAuthConfig<OAuthMastodonConfig, {
|
|
59
59
|
user: TUser;
|
|
60
60
|
tokens: MastodonTokens;
|
|
61
|
-
}>): import("
|
|
61
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
62
62
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { createError,
|
|
1
|
+
import { createError, defineEventHandler, deleteCookie, getCookie, getQuery, sendRedirect, setCookie, useRuntimeConfig } from "nuxt/server";
|
|
2
2
|
import { withQuery } from "ufo";
|
|
3
3
|
import { defu } from "defu";
|
|
4
4
|
import { $fetch } from "ofetch";
|
|
5
5
|
import { getOAuthRedirectURL, handleAccessTokenErrorResponse, handleInvalidState, handleState, isDevelopment, requestAccessToken } from "../utils.js";
|
|
6
|
-
import { useRuntimeConfig } from "#imports";
|
|
7
6
|
const FLOW_COOKIE_NAME = "nuxt-auth-mastodon-flow";
|
|
8
7
|
const appRegistry = /* @__PURE__ */ new Map();
|
|
9
8
|
const pendingRegistrations = /* @__PURE__ */ new Map();
|
|
@@ -64,15 +63,15 @@ async function getOrRegisterApp(instance, redirectURL, scope, clientName) {
|
|
|
64
63
|
return registration;
|
|
65
64
|
}
|
|
66
65
|
export function defineOAuthMastodonEventHandler({ config: userConfig, onSuccess, onError }) {
|
|
67
|
-
return
|
|
68
|
-
const config = defu({}, userConfig, useRuntimeConfig(
|
|
66
|
+
return defineEventHandler(async (event) => {
|
|
67
|
+
const config = defu({}, userConfig, useRuntimeConfig().oauth?.mastodon, {
|
|
69
68
|
clientName: "Nuxt Auth Utils"
|
|
70
69
|
});
|
|
71
70
|
config.scope ||= ["read"];
|
|
72
71
|
const query = getQuery(event);
|
|
73
72
|
if (query.error) {
|
|
74
73
|
const error = createError({
|
|
75
|
-
|
|
74
|
+
status: 401,
|
|
76
75
|
message: `Mastodon login failed: ${query.error || "Unknown error"}`,
|
|
77
76
|
data: query
|
|
78
77
|
});
|
|
@@ -86,7 +85,7 @@ export function defineOAuthMastodonEventHandler({ config: userConfig, onSuccess,
|
|
|
86
85
|
const rawInstance = query.instance?.toString() || config.instance;
|
|
87
86
|
if (!rawInstance) {
|
|
88
87
|
const error = createError({
|
|
89
|
-
|
|
88
|
+
status: 400,
|
|
90
89
|
message: "Mastodon login failed: missing instance. Provide it via the `instance` query parameter (e.g. `/auth/mastodon?instance=mastodon.social`), a full handle (`@user@mastodon.social`), or the `instance` config/`NUXT_OAUTH_MASTODON_INSTANCE` env variable."
|
|
91
90
|
});
|
|
92
91
|
if (!onError) throw error;
|
|
@@ -95,7 +94,7 @@ export function defineOAuthMastodonEventHandler({ config: userConfig, onSuccess,
|
|
|
95
94
|
const instance2 = resolveInstanceDomain(rawInstance);
|
|
96
95
|
if (!isPubliclyAddressableInstance(instance2)) {
|
|
97
96
|
const error = createError({
|
|
98
|
-
|
|
97
|
+
status: 400,
|
|
99
98
|
message: `Mastodon login failed: "${instance2}" is not a valid instance domain.`
|
|
100
99
|
});
|
|
101
100
|
if (!onError) throw error;
|
|
@@ -106,7 +105,7 @@ export function defineOAuthMastodonEventHandler({ config: userConfig, onSuccess,
|
|
|
106
105
|
app = await getOrRegisterApp(instance2, redirectURL, scope, config.clientName || "Nuxt Auth Utils");
|
|
107
106
|
} catch {
|
|
108
107
|
const error = createError({
|
|
109
|
-
|
|
108
|
+
status: 500,
|
|
110
109
|
message: `Mastodon login failed: could not register the application with instance "${instance2}". Make sure it is a reachable Mastodon (or compatible) server.`
|
|
111
110
|
});
|
|
112
111
|
if (!onError) throw error;
|
|
@@ -141,7 +140,7 @@ export function defineOAuthMastodonEventHandler({ config: userConfig, onSuccess,
|
|
|
141
140
|
}
|
|
142
141
|
if (!flowState || !isPubliclyAddressableInstance(flowState.instance)) {
|
|
143
142
|
const error = createError({
|
|
144
|
-
|
|
143
|
+
status: 400,
|
|
145
144
|
message: "Mastodon login failed: could not recover the application credentials for this login (missing or invalid flow cookie, the flow may have taken too long or cookies are blocked)."
|
|
146
145
|
});
|
|
147
146
|
if (!onError) throw error;
|
|
@@ -51,4 +51,4 @@ export interface OAuthMicrosoftConfig {
|
|
|
51
51
|
*/
|
|
52
52
|
redirectURL?: string;
|
|
53
53
|
}
|
|
54
|
-
export declare function defineOAuthMicrosoftEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthMicrosoftConfig>): import("
|
|
54
|
+
export declare function defineOAuthMicrosoftEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthMicrosoftConfig>): 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 defineOAuthMicrosoftEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.microsoft, {
|
|
9
9
|
authorizationParams: {}
|
|
10
10
|
});
|
|
11
11
|
const query = getQuery(event);
|
|
@@ -58,7 +58,7 @@ export function defineOAuthMicrosoftEventHandler({ config, onSuccess, onError })
|
|
|
58
58
|
});
|
|
59
59
|
if (user.error) {
|
|
60
60
|
const error = createError({
|
|
61
|
-
|
|
61
|
+
status: 401,
|
|
62
62
|
message: `Microsoft login failed: ${user.error || "Unknown error"}`,
|
|
63
63
|
data: user
|
|
64
64
|
});
|
|
@@ -211,5 +211,5 @@ interface OIDCConfiguration {
|
|
|
211
211
|
export declare function defineOAuthOidcEventHandler<TUser = OidcUser>({ config, onSuccess, onError }: OAuthConfig<OAuthOidcConfig, {
|
|
212
212
|
user: TUser;
|
|
213
213
|
tokens: OidcTokens;
|
|
214
|
-
}>): import("
|
|
214
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
215
215
|
export {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "
|
|
1
|
+
import { defineEventHandler, createError, getQuery, sendRedirect, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
2
3
|
import { defu } from "defu";
|
|
3
|
-
import { createError, eventHandler, getQuery, sendRedirect } from "h3";
|
|
4
4
|
import { withQuery } from "ufo";
|
|
5
5
|
import { getOAuthRedirectURL, handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, handlePkceVerifier, handleState, requestAccessToken, handleNonce, parseJwt } from "../utils.js";
|
|
6
6
|
export function defineOAuthOidcEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth.oidc);
|
|
9
9
|
const query = getQuery(event);
|
|
10
10
|
if (query.error) {
|
|
11
11
|
const error = createError({
|
|
12
|
-
|
|
12
|
+
status: 401,
|
|
13
13
|
message: `OIDC login failed: ${query.error || "Unknown error"}`,
|
|
14
14
|
data: query
|
|
15
15
|
});
|
|
@@ -67,7 +67,7 @@ export function defineOAuthOidcEventHandler({ config, onSuccess, onError }) {
|
|
|
67
67
|
const claims = parseJwt(tokens.id_token);
|
|
68
68
|
if (claims.nonce !== nonce) {
|
|
69
69
|
const error = createError({
|
|
70
|
-
|
|
70
|
+
status: 401,
|
|
71
71
|
message: "OIDC login failed: nonce mismatch"
|
|
72
72
|
});
|
|
73
73
|
if (!onError) throw error;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequestEvent } from 'nuxt/server';
|
|
2
2
|
import type { OAuthConfig } from '#auth-utils';
|
|
3
3
|
export interface OpenIdConfig {
|
|
4
4
|
authorization_endpoint: string;
|
|
@@ -13,8 +13,8 @@ export interface OAuthConfigExt<TConfig, TResult = {
|
|
|
13
13
|
openIdConfig: OpenIdConfig;
|
|
14
14
|
}> extends OAuthConfig<TConfig, TResult> {
|
|
15
15
|
config?: TConfig;
|
|
16
|
-
onSuccess: (event:
|
|
17
|
-
onError?: (event:
|
|
16
|
+
onSuccess: (event: RequestEvent, result: TResult) => unknown;
|
|
17
|
+
onError?: (event: RequestEvent, error: unknown) => unknown;
|
|
18
18
|
}
|
|
19
19
|
export interface OAuthOktaConfig {
|
|
20
20
|
/**
|
|
@@ -85,4 +85,4 @@ export interface OAuthOktaConfig {
|
|
|
85
85
|
*/
|
|
86
86
|
openIdConfigCacheTTL?: number;
|
|
87
87
|
}
|
|
88
|
-
export declare function defineOAuthOktaEventHandler({ config, onSuccess, onError }: OAuthConfigExt<OAuthOktaConfig>): import("
|
|
88
|
+
export declare function defineOAuthOktaEventHandler({ config, onSuccess, onError }: OAuthConfigExt<OAuthOktaConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
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, handleState, handleInvalidState, handleAccessTokenErrorResponse, getOAuthRedirectURL, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
const openIdConfigCache = /* @__PURE__ */ new Map();
|
|
7
7
|
const DEFAULT_CACHE_TTL = 1e3 * 60 * 60 * 24;
|
|
8
8
|
export function defineOAuthOktaEventHandler({ config, onSuccess, onError }) {
|
|
@@ -23,8 +23,8 @@ export function defineOAuthOktaEventHandler({ config, onSuccess, onError }) {
|
|
|
23
23
|
}
|
|
24
24
|
return result;
|
|
25
25
|
}
|
|
26
|
-
return
|
|
27
|
-
const runtimeConfig = useRuntimeConfig(
|
|
26
|
+
return defineEventHandler(async (event) => {
|
|
27
|
+
const runtimeConfig = useRuntimeConfig();
|
|
28
28
|
config = defu(config, runtimeConfig.oauth?.okta, {
|
|
29
29
|
authorizationParams: {}
|
|
30
30
|
});
|
|
@@ -34,7 +34,7 @@ export function defineOAuthOktaEventHandler({ config, onSuccess, onError }) {
|
|
|
34
34
|
const query = getQuery(event);
|
|
35
35
|
if (query.error) {
|
|
36
36
|
const error = createError({
|
|
37
|
-
|
|
37
|
+
status: 401,
|
|
38
38
|
message: `Okta login failed: ${query.error || "Unknown error"} - ${query.error_description || ""}`,
|
|
39
39
|
data: query
|
|
40
40
|
});
|
|
@@ -53,7 +53,7 @@ export function defineOAuthOktaEventHandler({ config, onSuccess, onError }) {
|
|
|
53
53
|
openIdConfigCache.delete(openIdConfigurationUrl2);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
let openIdConfig2
|
|
56
|
+
let openIdConfig2;
|
|
57
57
|
try {
|
|
58
58
|
openIdConfig2 = await $fetch(openIdConfigurationUrl2);
|
|
59
59
|
if (openIdConfig2) {
|
|
@@ -79,7 +79,7 @@ export function defineOAuthOktaEventHandler({ config, onSuccess, onError }) {
|
|
|
79
79
|
} else {
|
|
80
80
|
console.error("Failed to fetch Okta OpenID configuration. Please check your Okta domain and network connectivity:", error);
|
|
81
81
|
const err = createError({
|
|
82
|
-
|
|
82
|
+
status: 500,
|
|
83
83
|
message: "Could not get Okta OpenID configuration. Please verify that your Okta domain is correct and reachable, and that the OpenID configuration endpoint is accessible.",
|
|
84
84
|
data: error
|
|
85
85
|
});
|
|
@@ -136,7 +136,7 @@ export function defineOAuthOktaEventHandler({ config, onSuccess, onError }) {
|
|
|
136
136
|
}
|
|
137
137
|
if (!tokens.access_token || typeof tokens.access_token !== "string" || !tokens.token_type || typeof tokens.token_type !== "string") {
|
|
138
138
|
const err = createError({
|
|
139
|
-
|
|
139
|
+
status: 400,
|
|
140
140
|
message: "Invalid token response from Okta",
|
|
141
141
|
data: tokens
|
|
142
142
|
});
|
|
@@ -154,7 +154,7 @@ export function defineOAuthOktaEventHandler({ config, onSuccess, onError }) {
|
|
|
154
154
|
});
|
|
155
155
|
} catch (error) {
|
|
156
156
|
const err = createError({
|
|
157
|
-
|
|
157
|
+
status: 410,
|
|
158
158
|
message: `Could not get Okta user info - ${error instanceof Error ? error.message : String(error)}`,
|
|
159
159
|
data: tokens
|
|
160
160
|
});
|
|
@@ -48,4 +48,4 @@ export interface OAuthOryConfig {
|
|
|
48
48
|
*/
|
|
49
49
|
userURL?: string;
|
|
50
50
|
}
|
|
51
|
-
export declare function defineOAuthOryEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthOryConfig>): import("
|
|
51
|
+
export declare function defineOAuthOryEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthOryConfig>): 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 {
|
|
@@ -10,10 +11,9 @@ import {
|
|
|
10
11
|
handleState,
|
|
11
12
|
requestAccessToken
|
|
12
13
|
} from "../utils.js";
|
|
13
|
-
import { createError, useRuntimeConfig } from "#imports";
|
|
14
14
|
export function defineOAuthOryEventHandler({ config, onSuccess, onError }) {
|
|
15
|
-
return
|
|
16
|
-
config = defu(config, useRuntimeConfig(
|
|
15
|
+
return defineEventHandler(async (event) => {
|
|
16
|
+
config = defu(config, useRuntimeConfig().oauth?.ory, {
|
|
17
17
|
scope: ["openid", "offline"],
|
|
18
18
|
sdkURL: "https://playground.projects.oryapis.com",
|
|
19
19
|
authorizationURL: "/oauth2/auth",
|
|
@@ -24,7 +24,7 @@ export function defineOAuthOryEventHandler({ config, onSuccess, onError }) {
|
|
|
24
24
|
const query = getQuery(event);
|
|
25
25
|
if (query.error) {
|
|
26
26
|
const error = createError({
|
|
27
|
-
|
|
27
|
+
status: 401,
|
|
28
28
|
message: `Ory login failed: ${query.error || "Unknown error"}`,
|
|
29
29
|
data: query
|
|
30
30
|
});
|
|
@@ -86,7 +86,7 @@ export function defineOAuthOryEventHandler({ config, onSuccess, onError }) {
|
|
|
86
86
|
});
|
|
87
87
|
if (user.error) {
|
|
88
88
|
const error = createError({
|
|
89
|
-
|
|
89
|
+
status: 401,
|
|
90
90
|
message: `Ory userinfo failed: ${user.error || "Unknown error"}`,
|
|
91
91
|
data: user
|
|
92
92
|
});
|
|
@@ -39,4 +39,4 @@ export interface OAuthOsuConfig {
|
|
|
39
39
|
*/
|
|
40
40
|
redirectURL?: string;
|
|
41
41
|
}
|
|
42
|
-
export declare function defineOAuthOsuEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthOsuConfig>): import("
|
|
42
|
+
export declare function defineOAuthOsuEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthOsuConfig>): 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, requestAccessToken, handleState, handleInvalidState } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export function defineOAuthOsuEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.osu, {
|
|
9
9
|
authorizationURL: "https://osu.ppy.sh/oauth/authorize",
|
|
10
10
|
tokenURL: "https://osu.ppy.sh/oauth/token",
|
|
11
11
|
authorizationParams: {}
|
|
@@ -49,4 +49,4 @@ export interface OAuthPaypalConfig {
|
|
|
49
49
|
*/
|
|
50
50
|
redirectURL?: string;
|
|
51
51
|
}
|
|
52
|
-
export declare function defineOAuthPaypalEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthPaypalConfig>): import("
|
|
52
|
+
export declare function defineOAuthPaypalEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthPaypalConfig>): 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 defineOAuthPaypalEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.paypal, {
|
|
9
9
|
sandbox: import.meta.dev,
|
|
10
10
|
authorizationURL: "https://www.paypal.com/signin/authorize",
|
|
11
11
|
tokenURL: "https://api-m.paypal.com/v1/oauth2/token",
|
|
@@ -74,7 +74,7 @@ export function defineOAuthPaypalEventHandler({ config, onSuccess, onError }) {
|
|
|
74
74
|
const user = users;
|
|
75
75
|
if (!user) {
|
|
76
76
|
const error = createError({
|
|
77
|
-
|
|
77
|
+
status: 500,
|
|
78
78
|
message: "Could not get PayPal user",
|
|
79
79
|
data: tokens
|
|
80
80
|
});
|
|
@@ -46,4 +46,4 @@ export interface OAuthPolarConfig {
|
|
|
46
46
|
*/
|
|
47
47
|
redirectURL?: string;
|
|
48
48
|
}
|
|
49
|
-
export declare function defineOAuthPolarEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthPolarConfig>): import("
|
|
49
|
+
export declare function defineOAuthPolarEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthPolarConfig>): 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 { handleAccessTokenErrorResponse, handleInvalidState, handleMissingConfiguration, getOAuthRedirectURL, handleState, requestAccessToken } from "../utils.js";
|
|
5
|
-
import { useRuntimeConfig, createError } from "#imports";
|
|
6
6
|
export function defineOAuthPolarEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.polar, {
|
|
9
9
|
authorizationURL: "https://polar.sh/oauth2/authorize",
|
|
10
10
|
tokenURL: "https://api.polar.sh/v1/oauth2/token"
|
|
11
11
|
});
|
|
@@ -57,7 +57,7 @@ export function defineOAuthPolarEventHandler({ config, onSuccess, onError }) {
|
|
|
57
57
|
});
|
|
58
58
|
if (!user) {
|
|
59
59
|
const error = createError({
|
|
60
|
-
|
|
60
|
+
status: 500,
|
|
61
61
|
message: "Could not get Polar user",
|
|
62
62
|
data: tokens
|
|
63
63
|
});
|
|
@@ -70,5 +70,5 @@ interface RiotGamesTokens {
|
|
|
70
70
|
export declare function defineOAuthRiotGamesEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthRiotGamesConfig, {
|
|
71
71
|
user: RiotGamesUser;
|
|
72
72
|
tokens: RiotGamesTokens;
|
|
73
|
-
}>): import("
|
|
73
|
+
}>): import("nuxt/server").EventHandler<Promise<any>>;
|
|
74
74
|
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 defineOAuthRiotGamesEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.riotgames, {
|
|
9
9
|
authorizationURL: "https://auth.riotgames.com/authorize",
|
|
10
10
|
tokenURL: "https://auth.riotgames.com/token",
|
|
11
11
|
apiURL: "https://auth.riotgames.com",
|
|
@@ -14,7 +14,7 @@ export function defineOAuthRiotGamesEventHandler({ 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: `RiotGames login failed: ${query.error || "Unknown error"}`,
|
|
19
19
|
data: query
|
|
20
20
|
});
|
|
@@ -123,4 +123,4 @@ export interface OAuthRobloxUser {
|
|
|
123
123
|
visibility: 'SOCIAL_NETWORK_VISIBILITY_UNSPECIFIED' | 'NO_ONE' | 'FRIENDS' | 'FRIENDS_AND_FOLLOWING' | 'FRIENDS_FOLLOWING_AND_FOLLOWERS' | 'EVERYONE';
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
export declare function defineOAuthRobloxEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthRobloxConfig>): import("
|
|
126
|
+
export declare function defineOAuthRobloxEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthRobloxConfig>): 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 defineOAuthRobloxEventHandler({ config, onSuccess, onError }) {
|
|
7
|
-
return
|
|
8
|
-
config = defu(config, useRuntimeConfig(
|
|
7
|
+
return defineEventHandler(async (event) => {
|
|
8
|
+
config = defu(config, useRuntimeConfig().oauth?.roblox, {
|
|
9
9
|
authorizationURL: "https://apis.roblox.com/oauth/v1/authorize",
|
|
10
10
|
tokenURL: "https://apis.roblox.com/oauth/v1/token",
|
|
11
11
|
authorizationParams: {}
|
|
@@ -48,4 +48,4 @@ export interface OAuthSalesforceConfig {
|
|
|
48
48
|
*/
|
|
49
49
|
redirectURL?: string;
|
|
50
50
|
}
|
|
51
|
-
export declare function defineOAuthSalesforceEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthSalesforceConfig>): import("
|
|
51
|
+
export declare function defineOAuthSalesforceEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthSalesforceConfig>): import("nuxt/server").EventHandler<Promise<any>>;
|