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, 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 eventHandler(async (event) => {
12
- const runtimeConfig = useRuntimeConfig(event).oauth?.salesforce;
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.seznam, {
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
26
+ export declare function defineOAuthShopifyCustomerEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthShopifyCustomerConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,15 +1,15 @@
1
- import { createError, 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 { 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 eventHandler(async (event) => {
12
- config = defu(config, useRuntimeConfig(event).oauth?.shopifyCustomer, {});
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
- statusCode: 400,
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
- statusCode: 400,
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
- statusCode: 400,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
41
+ export declare function defineOAuthSlackEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthSlackConfig>): 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 defineOAuthSlackEventHandler({
7
7
  config,
8
8
  onSuccess,
9
9
  onError
10
10
  }) {
11
- return eventHandler(async (event) => {
12
- const runtimeConfig = useRuntimeConfig(event).oauth?.slack;
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
93
+ }>): import("nuxt/server").EventHandler<Promise<any>>;
94
94
  export {};
@@ -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 defineOAuthSpotifyEventHandler({ config, onSuccess, onError }) {
7
- return eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.spotify, {
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
20
+ export declare function defineOAuthSteamEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSteamConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,21 +1,21 @@
1
- import { eventHandler, createError, getQuery, getRequestURL, sendRedirect } from "h3";
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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.steam, {
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 || getRequestURL(event).href, { state });
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
- statusCode: 400,
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
- statusCode: 400,
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
119
+ }>): 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,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 eventHandler(async (event) => {
19
- config = defu(config, useRuntimeConfig(event).oauth?.strava);
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
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 eventHandler(async (event) => {
9
- config = defu(config, useRuntimeConfig(event).oauth?.tiktok, {
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
- statusCode: 500,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
70
+ }>): import("nuxt/server").EventHandler<Promise<any>>;
71
71
  export {};
@@ -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 defineOAuthTwitchEventHandler({ config, onSuccess, onError }) {
7
- return eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.twitch, {
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
- statusCode: 500,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
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 eventHandler(async (event) => {
20
- config = defu(config, useRuntimeConfig(event).oauth?.vk, {
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
- statusCode: 500,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
67
+ }>): 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 {
@@ -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
- statusCode: 401,
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 eventHandler(async (event) => {
31
- config = defu(config, useRuntimeConfig(event).oauth?.wechat, {
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
- statusCode: 401,
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
- statusCode: 401,
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
66
+ }>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,11 +1,10 @@
1
- import { eventHandler, getQuery, sendRedirect, getRequestIP, getRequestHeader } from "h3";
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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.workos, { screen_hint: "sign-in" });
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
46
+ export declare function defineOAuthXEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthXConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,6 +1,6 @@
1
- import { useRuntimeConfig } from "#imports";
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 eventHandler(async (event) => {
20
- config = defu(config, useRuntimeConfig(event).oauth?.x, {
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
31
+ export declare function defineOAuthXSUAAEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthXSUAAConfig>): 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 defineOAuthXSUAAEventHandler({ config, onSuccess, onError }) {
7
- return eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.xsuaa);
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
46
+ export declare function defineOAuthYandexEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthYandexConfig>): 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,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 eventHandler(async (event) => {
19
- config = defu(config, useRuntimeConfig(event).oauth?.yandex, {
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
110
+ }>): 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,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 eventHandler(async (event) => {
35
- const runtimeConfig = useRuntimeConfig(event).oauth?.zendesk;
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("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
37
+ export declare function defineOAuthZitadelEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthZitadelConfig>): import("nuxt/server").EventHandler<Promise<any>>;
@@ -1,17 +1,17 @@
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 { 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 eventHandler(async (event) => {
8
- config = defu(config, useRuntimeConfig(event).oauth?.zitadel, {
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
- statusCode: 401,
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
- statusCode: 500,
78
+ status: 500,
79
79
  message: "Could not get Zitadel user",
80
80
  data: tokens
81
81
  });