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.
Files changed (140) hide show
  1. package/README.md +91 -16
  2. package/dist/module.d.mts +3 -3
  3. package/dist/module.json +5 -2
  4. package/dist/module.mjs +28 -31
  5. package/dist/runtime/app/components/AuthState.d.vue.ts +20 -0
  6. package/dist/runtime/app/composables/session.js +3 -2
  7. package/dist/runtime/server/api/session.delete.d.ts +1 -1
  8. package/dist/runtime/server/api/session.delete.js +2 -2
  9. package/dist/runtime/server/api/session.get.d.ts +1 -1
  10. package/dist/runtime/server/api/session.get.js +2 -2
  11. package/dist/runtime/server/lib/atproto/bluesky.d.ts +3 -3
  12. package/dist/runtime/server/lib/atproto/bluesky.js +6 -6
  13. package/dist/runtime/server/lib/oauth/apple.d.ts +1 -1
  14. package/dist/runtime/server/lib/oauth/apple.js +3 -4
  15. package/dist/runtime/server/lib/oauth/atlassian.d.ts +1 -1
  16. package/dist/runtime/server/lib/oauth/atlassian.js +8 -8
  17. package/dist/runtime/server/lib/oauth/auth0.d.ts +1 -1
  18. package/dist/runtime/server/lib/oauth/auth0.js +4 -4
  19. package/dist/runtime/server/lib/oauth/authentik.d.ts +1 -1
  20. package/dist/runtime/server/lib/oauth/authentik.js +6 -6
  21. package/dist/runtime/server/lib/oauth/azureb2c.d.ts +1 -1
  22. package/dist/runtime/server/lib/oauth/azureb2c.js +5 -5
  23. package/dist/runtime/server/lib/oauth/battledotnet.d.ts +1 -1
  24. package/dist/runtime/server/lib/oauth/battledotnet.js +6 -6
  25. package/dist/runtime/server/lib/oauth/box.d.ts +1 -1
  26. package/dist/runtime/server/lib/oauth/box.js +5 -5
  27. package/dist/runtime/server/lib/oauth/cloudflare.d.ts +1 -1
  28. package/dist/runtime/server/lib/oauth/cloudflare.js +5 -5
  29. package/dist/runtime/server/lib/oauth/cognito.d.ts +1 -1
  30. package/dist/runtime/server/lib/oauth/cognito.js +4 -4
  31. package/dist/runtime/server/lib/oauth/discord.d.ts +1 -1
  32. package/dist/runtime/server/lib/oauth/discord.js +4 -4
  33. package/dist/runtime/server/lib/oauth/dropbox.d.ts +1 -1
  34. package/dist/runtime/server/lib/oauth/dropbox.js +5 -5
  35. package/dist/runtime/server/lib/oauth/facebook.d.ts +1 -1
  36. package/dist/runtime/server/lib/oauth/facebook.js +7 -7
  37. package/dist/runtime/server/lib/oauth/gitea.d.ts +1 -1
  38. package/dist/runtime/server/lib/oauth/gitea.js +5 -5
  39. package/dist/runtime/server/lib/oauth/github.d.ts +1 -1
  40. package/dist/runtime/server/lib/oauth/github.js +6 -6
  41. package/dist/runtime/server/lib/oauth/gitlab.d.ts +1 -1
  42. package/dist/runtime/server/lib/oauth/gitlab.js +5 -5
  43. package/dist/runtime/server/lib/oauth/google.d.ts +1 -1
  44. package/dist/runtime/server/lib/oauth/google.js +4 -4
  45. package/dist/runtime/server/lib/oauth/heroku.d.ts +1 -1
  46. package/dist/runtime/server/lib/oauth/heroku.js +5 -5
  47. package/dist/runtime/server/lib/oauth/hubspot.d.ts +1 -1
  48. package/dist/runtime/server/lib/oauth/hubspot.js +4 -4
  49. package/dist/runtime/server/lib/oauth/instagram.d.ts +1 -1
  50. package/dist/runtime/server/lib/oauth/instagram.js +6 -6
  51. package/dist/runtime/server/lib/oauth/keycloak.d.ts +1 -1
  52. package/dist/runtime/server/lib/oauth/keycloak.js +6 -6
  53. package/dist/runtime/server/lib/oauth/kick.d.ts +1 -1
  54. package/dist/runtime/server/lib/oauth/kick.js +5 -5
  55. package/dist/runtime/server/lib/oauth/line.d.ts +1 -1
  56. package/dist/runtime/server/lib/oauth/line.js +6 -6
  57. package/dist/runtime/server/lib/oauth/linear.d.ts +1 -1
  58. package/dist/runtime/server/lib/oauth/linear.js +6 -6
  59. package/dist/runtime/server/lib/oauth/linkedin.d.ts +1 -1
  60. package/dist/runtime/server/lib/oauth/linkedin.js +4 -4
  61. package/dist/runtime/server/lib/oauth/livechat.d.ts +1 -1
  62. package/dist/runtime/server/lib/oauth/livechat.js +4 -4
  63. package/dist/runtime/server/lib/oauth/mastodon.d.ts +1 -1
  64. package/dist/runtime/server/lib/oauth/mastodon.js +8 -9
  65. package/dist/runtime/server/lib/oauth/microsoft.d.ts +1 -1
  66. package/dist/runtime/server/lib/oauth/microsoft.js +5 -5
  67. package/dist/runtime/server/lib/oauth/oidc.d.ts +1 -1
  68. package/dist/runtime/server/lib/oauth/oidc.js +6 -6
  69. package/dist/runtime/server/lib/oauth/okta.d.ts +4 -4
  70. package/dist/runtime/server/lib/oauth/okta.js +9 -9
  71. package/dist/runtime/server/lib/oauth/ory.d.ts +1 -1
  72. package/dist/runtime/server/lib/oauth/ory.js +6 -6
  73. package/dist/runtime/server/lib/oauth/osu.d.ts +1 -1
  74. package/dist/runtime/server/lib/oauth/osu.js +4 -4
  75. package/dist/runtime/server/lib/oauth/paypal.d.ts +1 -1
  76. package/dist/runtime/server/lib/oauth/paypal.js +5 -5
  77. package/dist/runtime/server/lib/oauth/polar.d.ts +1 -1
  78. package/dist/runtime/server/lib/oauth/polar.js +5 -5
  79. package/dist/runtime/server/lib/oauth/riotgames.d.ts +1 -1
  80. package/dist/runtime/server/lib/oauth/riotgames.js +5 -5
  81. package/dist/runtime/server/lib/oauth/roblox.d.ts +1 -1
  82. package/dist/runtime/server/lib/oauth/roblox.js +4 -4
  83. package/dist/runtime/server/lib/oauth/salesforce.d.ts +1 -1
  84. package/dist/runtime/server/lib/oauth/salesforce.js +5 -5
  85. package/dist/runtime/server/lib/oauth/seznam.d.ts +1 -1
  86. package/dist/runtime/server/lib/oauth/seznam.js +4 -4
  87. package/dist/runtime/server/lib/oauth/shopifyCustomer.d.ts +1 -1
  88. package/dist/runtime/server/lib/oauth/shopifyCustomer.js +7 -7
  89. package/dist/runtime/server/lib/oauth/slack.d.ts +1 -1
  90. package/dist/runtime/server/lib/oauth/slack.js +5 -5
  91. package/dist/runtime/server/lib/oauth/spotify.d.ts +49 -2
  92. package/dist/runtime/server/lib/oauth/spotify.js +4 -4
  93. package/dist/runtime/server/lib/oauth/steam.d.ts +1 -1
  94. package/dist/runtime/server/lib/oauth/steam.js +7 -7
  95. package/dist/runtime/server/lib/oauth/strava.d.ts +1 -1
  96. package/dist/runtime/server/lib/oauth/strava.js +5 -5
  97. package/dist/runtime/server/lib/oauth/tiktok.d.ts +1 -1
  98. package/dist/runtime/server/lib/oauth/tiktok.js +5 -5
  99. package/dist/runtime/server/lib/oauth/twitch.d.ts +1 -1
  100. package/dist/runtime/server/lib/oauth/twitch.js +5 -5
  101. package/dist/runtime/server/lib/oauth/vk.d.ts +1 -1
  102. package/dist/runtime/server/lib/oauth/vk.js +5 -5
  103. package/dist/runtime/server/lib/oauth/wechat.d.ts +1 -1
  104. package/dist/runtime/server/lib/oauth/wechat.js +7 -7
  105. package/dist/runtime/server/lib/oauth/workos.d.ts +1 -1
  106. package/dist/runtime/server/lib/oauth/workos.js +3 -4
  107. package/dist/runtime/server/lib/oauth/x.d.ts +1 -1
  108. package/dist/runtime/server/lib/oauth/x.js +4 -4
  109. package/dist/runtime/server/lib/oauth/xsuaa.d.ts +1 -1
  110. package/dist/runtime/server/lib/oauth/xsuaa.js +4 -4
  111. package/dist/runtime/server/lib/oauth/yandex.d.ts +1 -1
  112. package/dist/runtime/server/lib/oauth/yandex.js +4 -4
  113. package/dist/runtime/server/lib/oauth/zendesk.d.ts +110 -0
  114. package/dist/runtime/server/lib/oauth/zendesk.js +109 -0
  115. package/dist/runtime/server/lib/oauth/zitadel.d.ts +1 -1
  116. package/dist/runtime/server/lib/oauth/zitadel.js +6 -6
  117. package/dist/runtime/server/lib/utils.d.ts +8 -8
  118. package/dist/runtime/server/lib/utils.js +5 -7
  119. package/dist/runtime/server/lib/webauthn/authenticate.d.ts +1 -1
  120. package/dist/runtime/server/lib/webauthn/authenticate.js +7 -8
  121. package/dist/runtime/server/lib/webauthn/register.d.ts +2 -2
  122. package/dist/runtime/server/lib/webauthn/register.js +9 -10
  123. package/dist/runtime/server/plugins/oauth-hash.d.ts +2 -0
  124. package/dist/runtime/server/plugins/oauth-hash.js +8 -0
  125. package/dist/runtime/server/routes/atproto/client-metadata.json.get.d.ts +1 -1
  126. package/dist/runtime/server/routes/atproto/client-metadata.json.get.js +5 -5
  127. package/dist/runtime/server/utils/atproto.d.ts +2 -2
  128. package/dist/runtime/server/utils/atproto.js +2 -3
  129. package/dist/runtime/server/utils/password.js +1 -1
  130. package/dist/runtime/server/utils/session.d.ts +29 -16
  131. package/dist/runtime/server/utils/session.js +72 -29
  132. package/dist/runtime/types/event.d.ts +27 -3
  133. package/dist/runtime/types/index.d.ts +1 -1
  134. package/dist/runtime/types/oauth-config.d.ts +4 -4
  135. package/dist/runtime/types/webauthn.d.ts +14 -15
  136. package/package.json +12 -9
  137. package/dist/runtime/server/plugins/oauth.d.ts +0 -2
  138. package/dist/runtime/server/plugins/oauth.js +0 -16
  139. package/dist/runtime/server/plugins/ws.d.ts +0 -2
  140. 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
  });
@@ -14,12 +14,15 @@ export interface OAuthSpotifyConfig {
14
14
  * Spotify OAuth Scope
15
15
  * @default []
16
16
  * @see https://developer.spotify.com/documentation/web-api/concepts/scopes
17
- * @example ['user-read-email']
17
+ * @example ['playlist-read-private']
18
18
  */
19
19
  scope?: string[];
20
20
  /**
21
21
  * Require email from user, adds the ['user-read-email'] scope if not present
22
+ *
23
+ * Spotify doesn't return the email to Development Mode apps created since February 11, 2026, nor to existing ones since March 9, 2026. Extended Quota Mode apps still receive it.
22
24
  * @default false
25
+ * @see https://developer.spotify.com/documentation/web-api/tutorials/february-2026-migration-guide
23
26
  */
24
27
  emailRequired?: boolean;
25
28
  /**
@@ -44,4 +47,48 @@ export interface OAuthSpotifyConfig {
44
47
  */
45
48
  redirectURL?: string;
46
49
  }
47
- export declare function defineOAuthSpotifyEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSpotifyConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
50
+ interface SpotifyUser {
51
+ /** Stable identifier, recommended by Spotify for account linking instead of `id` */
52
+ account_id: string;
53
+ display_name: string | null;
54
+ external_urls: {
55
+ spotify: string;
56
+ };
57
+ href: string;
58
+ id: string;
59
+ images: {
60
+ url: string;
61
+ height: number | null;
62
+ width: number | null;
63
+ }[];
64
+ type: string;
65
+ uri: string;
66
+ /** @deprecated Only returned to Extended Quota Mode apps since February 2026 */
67
+ country?: string;
68
+ /** @deprecated Only returned to Extended Quota Mode apps since February 2026 */
69
+ email?: string;
70
+ /** @deprecated Only returned to Extended Quota Mode apps since February 2026 */
71
+ explicit_content?: {
72
+ filter_enabled: boolean;
73
+ filter_locked: boolean;
74
+ };
75
+ /** @deprecated Only returned to Extended Quota Mode apps since February 2026 */
76
+ followers?: {
77
+ href: string | null;
78
+ total: number;
79
+ };
80
+ /** @deprecated Only returned to Extended Quota Mode apps since February 2026 */
81
+ product?: string;
82
+ }
83
+ interface SpotifyTokens {
84
+ access_token: string;
85
+ token_type: string;
86
+ scope: string;
87
+ expires_in: number;
88
+ refresh_token: string;
89
+ }
90
+ export declare function defineOAuthSpotifyEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSpotifyConfig, {
91
+ user: SpotifyUser;
92
+ tokens: SpotifyTokens;
93
+ }>): import("nuxt/server").EventHandler<Promise<any>>;
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,11 +1,11 @@
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);
@@ -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"