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.
Files changed (142) hide show
  1. package/README.md +118 -15
  2. package/dist/module.d.mts +3 -3
  3. package/dist/module.json +4 -1
  4. package/dist/module.mjs +18 -31
  5. package/dist/runtime/app/composables/session.js +3 -2
  6. package/dist/runtime/server/api/session.delete.d.ts +1 -1
  7. package/dist/runtime/server/api/session.delete.js +2 -2
  8. package/dist/runtime/server/api/session.get.d.ts +1 -1
  9. package/dist/runtime/server/api/session.get.js +6 -2
  10. package/dist/runtime/server/lib/atproto/bluesky.d.ts +3 -3
  11. package/dist/runtime/server/lib/atproto/bluesky.js +6 -6
  12. package/dist/runtime/server/lib/oauth/apple.d.ts +1 -1
  13. package/dist/runtime/server/lib/oauth/apple.js +3 -4
  14. package/dist/runtime/server/lib/oauth/atlassian.d.ts +1 -1
  15. package/dist/runtime/server/lib/oauth/atlassian.js +8 -8
  16. package/dist/runtime/server/lib/oauth/auth0.d.ts +1 -1
  17. package/dist/runtime/server/lib/oauth/auth0.js +4 -4
  18. package/dist/runtime/server/lib/oauth/authentik.d.ts +1 -1
  19. package/dist/runtime/server/lib/oauth/authentik.js +6 -6
  20. package/dist/runtime/server/lib/oauth/azureb2c.d.ts +1 -1
  21. package/dist/runtime/server/lib/oauth/azureb2c.js +5 -5
  22. package/dist/runtime/server/lib/oauth/battledotnet.d.ts +1 -1
  23. package/dist/runtime/server/lib/oauth/battledotnet.js +6 -6
  24. package/dist/runtime/server/lib/oauth/box.d.ts +1 -1
  25. package/dist/runtime/server/lib/oauth/box.js +5 -5
  26. package/dist/runtime/server/lib/oauth/cloudflare.d.ts +1 -1
  27. package/dist/runtime/server/lib/oauth/cloudflare.js +5 -5
  28. package/dist/runtime/server/lib/oauth/cognito.d.ts +1 -1
  29. package/dist/runtime/server/lib/oauth/cognito.js +4 -4
  30. package/dist/runtime/server/lib/oauth/discord.d.ts +1 -1
  31. package/dist/runtime/server/lib/oauth/discord.js +4 -4
  32. package/dist/runtime/server/lib/oauth/dropbox.d.ts +1 -1
  33. package/dist/runtime/server/lib/oauth/dropbox.js +5 -5
  34. package/dist/runtime/server/lib/oauth/facebook.d.ts +1 -1
  35. package/dist/runtime/server/lib/oauth/facebook.js +7 -7
  36. package/dist/runtime/server/lib/oauth/gitea.d.ts +1 -1
  37. package/dist/runtime/server/lib/oauth/gitea.js +5 -5
  38. package/dist/runtime/server/lib/oauth/github.d.ts +1 -1
  39. package/dist/runtime/server/lib/oauth/github.js +6 -6
  40. package/dist/runtime/server/lib/oauth/gitlab.d.ts +1 -1
  41. package/dist/runtime/server/lib/oauth/gitlab.js +5 -5
  42. package/dist/runtime/server/lib/oauth/google.d.ts +1 -1
  43. package/dist/runtime/server/lib/oauth/google.js +4 -4
  44. package/dist/runtime/server/lib/oauth/heroku.d.ts +1 -1
  45. package/dist/runtime/server/lib/oauth/heroku.js +5 -5
  46. package/dist/runtime/server/lib/oauth/hubspot.d.ts +1 -1
  47. package/dist/runtime/server/lib/oauth/hubspot.js +4 -4
  48. package/dist/runtime/server/lib/oauth/instagram.d.ts +1 -1
  49. package/dist/runtime/server/lib/oauth/instagram.js +6 -6
  50. package/dist/runtime/server/lib/oauth/keycloak.d.ts +1 -1
  51. package/dist/runtime/server/lib/oauth/keycloak.js +6 -6
  52. package/dist/runtime/server/lib/oauth/kick.d.ts +1 -1
  53. package/dist/runtime/server/lib/oauth/kick.js +5 -5
  54. package/dist/runtime/server/lib/oauth/line.d.ts +1 -1
  55. package/dist/runtime/server/lib/oauth/line.js +6 -6
  56. package/dist/runtime/server/lib/oauth/linear.d.ts +1 -1
  57. package/dist/runtime/server/lib/oauth/linear.js +6 -6
  58. package/dist/runtime/server/lib/oauth/linkedin.d.ts +1 -1
  59. package/dist/runtime/server/lib/oauth/linkedin.js +4 -4
  60. package/dist/runtime/server/lib/oauth/livechat.d.ts +1 -1
  61. package/dist/runtime/server/lib/oauth/livechat.js +4 -4
  62. package/dist/runtime/server/lib/oauth/mastodon.d.ts +1 -1
  63. package/dist/runtime/server/lib/oauth/mastodon.js +10 -11
  64. package/dist/runtime/server/lib/oauth/microsoft.d.ts +1 -1
  65. package/dist/runtime/server/lib/oauth/microsoft.js +5 -5
  66. package/dist/runtime/server/lib/oauth/oidc.d.ts +1 -1
  67. package/dist/runtime/server/lib/oauth/oidc.js +6 -6
  68. package/dist/runtime/server/lib/oauth/okta.d.ts +4 -4
  69. package/dist/runtime/server/lib/oauth/okta.js +8 -8
  70. package/dist/runtime/server/lib/oauth/ory.d.ts +1 -1
  71. package/dist/runtime/server/lib/oauth/ory.js +6 -6
  72. package/dist/runtime/server/lib/oauth/osu.d.ts +1 -1
  73. package/dist/runtime/server/lib/oauth/osu.js +4 -4
  74. package/dist/runtime/server/lib/oauth/paypal.d.ts +1 -1
  75. package/dist/runtime/server/lib/oauth/paypal.js +5 -5
  76. package/dist/runtime/server/lib/oauth/polar.d.ts +1 -1
  77. package/dist/runtime/server/lib/oauth/polar.js +5 -5
  78. package/dist/runtime/server/lib/oauth/riotgames.d.ts +1 -1
  79. package/dist/runtime/server/lib/oauth/riotgames.js +5 -5
  80. package/dist/runtime/server/lib/oauth/roblox.d.ts +1 -1
  81. package/dist/runtime/server/lib/oauth/roblox.js +4 -4
  82. package/dist/runtime/server/lib/oauth/salesforce.d.ts +1 -1
  83. package/dist/runtime/server/lib/oauth/salesforce.js +5 -5
  84. package/dist/runtime/server/lib/oauth/seznam.d.ts +1 -1
  85. package/dist/runtime/server/lib/oauth/seznam.js +4 -4
  86. package/dist/runtime/server/lib/oauth/shopifyCustomer.d.ts +1 -1
  87. package/dist/runtime/server/lib/oauth/shopifyCustomer.js +7 -7
  88. package/dist/runtime/server/lib/oauth/slack.d.ts +1 -1
  89. package/dist/runtime/server/lib/oauth/slack.js +5 -5
  90. package/dist/runtime/server/lib/oauth/spotify.d.ts +1 -1
  91. package/dist/runtime/server/lib/oauth/spotify.js +4 -4
  92. package/dist/runtime/server/lib/oauth/steam.d.ts +1 -1
  93. package/dist/runtime/server/lib/oauth/steam.js +9 -9
  94. package/dist/runtime/server/lib/oauth/strava.d.ts +1 -1
  95. package/dist/runtime/server/lib/oauth/strava.js +5 -5
  96. package/dist/runtime/server/lib/oauth/tiktok.d.ts +1 -1
  97. package/dist/runtime/server/lib/oauth/tiktok.js +5 -5
  98. package/dist/runtime/server/lib/oauth/twitch.d.ts +1 -1
  99. package/dist/runtime/server/lib/oauth/twitch.js +5 -5
  100. package/dist/runtime/server/lib/oauth/vk.d.ts +1 -1
  101. package/dist/runtime/server/lib/oauth/vk.js +5 -5
  102. package/dist/runtime/server/lib/oauth/wechat.d.ts +1 -1
  103. package/dist/runtime/server/lib/oauth/wechat.js +7 -7
  104. package/dist/runtime/server/lib/oauth/workos.d.ts +1 -1
  105. package/dist/runtime/server/lib/oauth/workos.js +3 -4
  106. package/dist/runtime/server/lib/oauth/x.d.ts +1 -1
  107. package/dist/runtime/server/lib/oauth/x.js +4 -4
  108. package/dist/runtime/server/lib/oauth/xsuaa.d.ts +1 -1
  109. package/dist/runtime/server/lib/oauth/xsuaa.js +4 -4
  110. package/dist/runtime/server/lib/oauth/yandex.d.ts +1 -1
  111. package/dist/runtime/server/lib/oauth/yandex.js +4 -4
  112. package/dist/runtime/server/lib/oauth/zendesk.d.ts +1 -1
  113. package/dist/runtime/server/lib/oauth/zendesk.js +4 -4
  114. package/dist/runtime/server/lib/oauth/zitadel.d.ts +1 -1
  115. package/dist/runtime/server/lib/oauth/zitadel.js +6 -6
  116. package/dist/runtime/server/lib/session.d.ts +11 -0
  117. package/dist/runtime/server/lib/session.js +33 -0
  118. package/dist/runtime/server/lib/utils.d.ts +9 -8
  119. package/dist/runtime/server/lib/utils.js +13 -11
  120. package/dist/runtime/server/lib/webauthn/authenticate.d.ts +1 -1
  121. package/dist/runtime/server/lib/webauthn/authenticate.js +8 -9
  122. package/dist/runtime/server/lib/webauthn/register.d.ts +2 -2
  123. package/dist/runtime/server/lib/webauthn/register.js +10 -11
  124. package/dist/runtime/server/plugins/oauth-hash.d.ts +2 -0
  125. package/dist/runtime/server/plugins/oauth-hash.js +8 -0
  126. package/dist/runtime/server/routes/atproto/client-metadata.json.get.d.ts +1 -1
  127. package/dist/runtime/server/routes/atproto/client-metadata.json.get.js +5 -5
  128. package/dist/runtime/server/utils/atproto.d.ts +2 -2
  129. package/dist/runtime/server/utils/atproto.js +3 -4
  130. package/dist/runtime/server/utils/password.js +1 -1
  131. package/dist/runtime/server/utils/session.d.ts +26 -17
  132. package/dist/runtime/server/utils/session.js +49 -29
  133. package/dist/runtime/types/event.d.ts +27 -3
  134. package/dist/runtime/types/index.d.ts +1 -1
  135. package/dist/runtime/types/oauth-config.d.ts +3 -3
  136. package/dist/runtime/types/session.d.ts +5 -2
  137. package/dist/runtime/types/webauthn.d.ts +14 -17
  138. package/package.json +10 -6
  139. package/dist/runtime/server/plugins/oauth.d.ts +0 -2
  140. package/dist/runtime/server/plugins/oauth.js +0 -16
  141. package/dist/runtime/server/plugins/ws.d.ts +0 -2
  142. package/dist/runtime/server/plugins/ws.js +0 -7
@@ -1,15 +1,15 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 defineOAuthAuthentikEventHandler({ config, onSuccess, onError }) {
7
- return eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.authentik);
7
+ return defineEventHandler(async (event) => {
8
+ config = defu(config, useRuntimeConfig().oauth?.authentik);
9
9
  const query = getQuery(event);
10
10
  if (query.error) {
11
11
  const error = createError({
12
- statusCode: 401,
12
+ status: 401,
13
13
  message: `Authentik login failed: ${query.error || "Unknown error"}`,
14
14
  data: query
15
15
  });
@@ -62,7 +62,7 @@ export function defineOAuthAuthentikEventHandler({ config, onSuccess, onError })
62
62
  });
63
63
  if (!user) {
64
64
  const error = createError({
65
- statusCode: 500,
65
+ status: 500,
66
66
  message: "Could not get Authentik user",
67
67
  data: tokens
68
68
  });
@@ -51,4 +51,4 @@ export interface OAuthAzureB2CConfig {
51
51
  */
52
52
  redirectURL?: string;
53
53
  }
54
- export declare function defineOAuthAzureB2CEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthAzureB2CConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
54
+ export declare function defineOAuthAzureB2CEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthAzureB2CConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,11 +1,11 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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, handlePkceVerifier, handleState, handleInvalidState } from "../utils.js";
5
- import { useRuntimeConfig, createError } from "#imports";
6
6
  export function defineOAuthAzureB2CEventHandler({ config, onSuccess, onError }) {
7
- return eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.azureb2c, {
7
+ return defineEventHandler(async (event) => {
8
+ config = defu(config, useRuntimeConfig().oauth?.azureb2c, {
9
9
  authorizationParams: {}
10
10
  });
11
11
  const query = getQuery(event);
@@ -63,7 +63,7 @@ export function defineOAuthAzureB2CEventHandler({ config, onSuccess, onError })
63
63
  });
64
64
  if (user.error) {
65
65
  const error = createError({
66
- statusCode: 401,
66
+ status: 401,
67
67
  message: `azureb2c login failed: ${user.error || "Unknown error"}`,
68
68
  data: user
69
69
  });
@@ -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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
48
+ export declare function defineOAuthBattledotnetEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthBattledotnetConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,11 +1,11 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.battledotnet, {
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
- statusCode: 401,
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
- statusCode: 500,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
94
+ }>): import("nuxt/server").EventHandler<Promise<any>>;
95
95
  export {};
@@ -1,11 +1,11 @@
1
- import { eventHandler, getQuery, sendRedirect, createError } from "h3";
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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.box, {
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
86
+ }>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,11 +1,11 @@
1
- import { eventHandler, getQuery, sendRedirect, createError } from "h3";
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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.cloudflare, {
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
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 eventHandler(async (event) => {
9
- config = defu(config, useRuntimeConfig(event).oauth?.cognito, {
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
53
+ export declare function defineOAuthDiscordEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthDiscordConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,11 +1,11 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.discord, {
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
47
+ export declare function defineOAuthDropboxEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthDropboxConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,11 +1,11 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.dropbox, {
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
- statusCode: 500,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
59
+ export declare function defineOAuthFacebookEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthFacebookConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,17 +1,17 @@
1
- import { eventHandler, getQuery, sendRedirect, createError } from "h3";
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 eventHandler(async (event) => {
13
- const apiVersion = config?.apiVersion || useRuntimeConfig(event).oauth?.facebook?.apiVersion || "v25.0";
14
- config = defu(config, useRuntimeConfig(event).oauth?.facebook, {
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
- statusCode: 401,
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
- statusCode: 500,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
51
+ export declare function defineOAuthGiteaEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGiteaConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,4 +1,5 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 eventHandler(async (event) => {
19
- const runtimeConfig = useRuntimeConfig(event).oauth?.gitea;
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
96
+ }>): import("nuxt/server").EventHandler<Promise<any>>;
97
97
  export {};
@@ -1,11 +1,11 @@
1
- import { eventHandler, getQuery, sendRedirect, createError } from "h3";
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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.github, {
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
- statusCode: 401,
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
- statusCode: 500,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
52
+ export declare function defineOAuthGitLabEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGitLabConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,4 +1,5 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 eventHandler(async (event) => {
19
- const runtimeConfig = useRuntimeConfig(event).oauth?.gitlab;
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
47
+ export declare function defineOAuthGoogleEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGoogleConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,15 +1,15 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 eventHandler(async (event) => {
12
- config = defu(config, useRuntimeConfig(event).oauth?.google, {
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
41
+ export declare function defineOAuthHerokuEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthHerokuConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,15 +1,15 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 eventHandler(async (event) => {
12
- const runtimeConfig = useRuntimeConfig(event).oauth?.heroku;
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
26
+ export declare function defineOAuthHubspotEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthHubspotConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,4 +1,5 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 eventHandler(async (event) => {
15
- config = defu(config, useRuntimeConfig(event).oauth?.hubspot);
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
48
+ export declare function defineOAuthInstagramEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthInstagramConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,15 +1,15 @@
1
- import { eventHandler, getQuery, sendRedirect, createError } from "h3";
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 eventHandler(async (event) => {
12
- config = defu(config, useRuntimeConfig(event).oauth?.instagram, {
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
- statusCode: 401,
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
- statusCode: 500,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
48
+ export declare function defineOAuthKeycloakEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthKeycloakConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,21 +1,21 @@
1
- import { eventHandler, getQuery, sendRedirect } from "h3";
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 eventHandler(async (event) => {
12
- config = defu(config, useRuntimeConfig(event).oauth?.keycloak, {
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
- statusCode: 401,
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
- statusCode: 500,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
54
+ }>): import("nuxt/server").EventHandler<Promise<any>>;
55
55
  export {};