nuxt-auth-utils 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "name": "auth-utils",
3
3
  "configKey": "auth",
4
- "version": "0.0.24"
4
+ "version": "0.0.25",
5
+ "builder": {
6
+ "@nuxt/module-builder": "0.6.0",
7
+ "unbuild": "2.0.0"
8
+ }
5
9
  }
package/dist/module.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { readFile, writeFile } from 'node:fs/promises';
2
- import { defineNuxtModule, createResolver, addImportsDir, addPlugin, addServerHandler } from '@nuxt/kit';
2
+ import { defineNuxtModule, createResolver, addImportsDir, addPlugin, addServerPlugin, addServerHandler } from '@nuxt/kit';
3
3
  import { join } from 'pathe';
4
4
  import { defu } from 'defu';
5
5
  import { randomUUID } from 'uncrypto';
@@ -37,6 +37,7 @@ const module = defineNuxtModule({
37
37
  ]
38
38
  });
39
39
  }
40
+ addServerPlugin(resolver.resolve("./runtime/server/plugins/oauth"));
40
41
  addServerHandler({
41
42
  handler: resolver.resolve("./runtime/server/api/session.delete"),
42
43
  route: "/api/_auth/session",
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<UserSessionRequired>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<import("../../types").UserSessionRequired>>;
2
2
  export default _default;
@@ -52,4 +52,4 @@ export interface OAuthAuth0Config {
52
52
  */
53
53
  authorizationParams?: Record<string, string>;
54
54
  }
55
- export declare function auth0EventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthAuth0Config>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
55
+ export declare function auth0EventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthAuth0Config>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -40,4 +40,4 @@ export interface OAuthBattledotnetConfig {
40
40
  */
41
41
  authorizationParams?: Record<string, string>;
42
42
  }
43
- export declare function battledotnetEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthBattledotnetConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
43
+ export declare function battledotnetEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthBattledotnetConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -31,4 +31,4 @@ export interface OAuthCognitoConfig {
31
31
  */
32
32
  authorizationParams?: Record<string, string>;
33
33
  }
34
- export declare function cognitoEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthCognitoConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
34
+ export declare function cognitoEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthCognitoConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -45,4 +45,4 @@ export interface OAuthDiscordConfig {
45
45
  */
46
46
  authorizationParams?: Record<string, string>;
47
47
  }
48
- export declare function discordEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthDiscordConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
48
+ export declare function discordEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthDiscordConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -17,6 +17,13 @@ export interface OAuthFacebookConfig {
17
17
  * @example [ 'email' ],
18
18
  */
19
19
  scope?: string[];
20
+ /**
21
+ * Facebook OAuth User Fields
22
+ * @default [ 'id', 'name'],
23
+ * @see https://developers.facebook.com/docs/graph-api/guides/field-expansion
24
+ * @example [ 'id', 'name', 'email' ],
25
+ */
26
+ fields?: string[];
20
27
  /**
21
28
  * Facebook OAuth Authorization URL
22
29
  * @default 'https://www.facebook.com/v19.0/dialog/oauth'
@@ -33,4 +40,4 @@ export interface OAuthFacebookConfig {
33
40
  */
34
41
  authorizationParams?: Record<string, string>;
35
42
  }
36
- export declare function facebookEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthFacebookConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
43
+ export declare function facebookEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthFacebookConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -72,8 +72,10 @@ export function facebookEventHandler({
72
72
  return onError(event, error);
73
73
  }
74
74
  const accessToken = tokens.access_token;
75
+ config.fields = config.fields || ["id", "name"];
76
+ const fields = config.fields.join(",");
75
77
  const user = await ofetch(
76
- `https://graph.facebook.com/v19.0/me?fields=id,name&access_token=${accessToken}`
78
+ `https://graph.facebook.com/v19.0/me?fields=${fields}&access_token=${accessToken}`
77
79
  );
78
80
  if (!user) {
79
81
  throw new Error("Facebook login failed: no user found");
@@ -39,4 +39,4 @@ export interface OAuthGitHubConfig {
39
39
  */
40
40
  authorizationParams?: Record<string, string>;
41
41
  }
42
- export declare function githubEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthGitHubConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
42
+ export declare function githubEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthGitHubConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -39,4 +39,4 @@ export interface OAuthGoogleConfig {
39
39
  */
40
40
  authorizationParams?: Record<string, string>;
41
41
  }
42
- export declare function googleEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGoogleConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
42
+ export declare function googleEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGoogleConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -33,4 +33,4 @@ export interface OAuthKeycloakConfig {
33
33
  */
34
34
  authorizationParams?: Record<string, string>;
35
35
  }
36
- export declare function keycloakEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthKeycloakConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
36
+ export declare function keycloakEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthKeycloakConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -39,4 +39,4 @@ export interface OAuthSpotifyConfig {
39
39
  */
40
40
  authorizationParams?: Record<string, string>;
41
41
  }
42
- export declare function spotifyEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSpotifyConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
42
+ export declare function spotifyEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthSpotifyConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -39,4 +39,4 @@ export interface OAuthTwitchConfig {
39
39
  */
40
40
  authorizationParams?: Record<string, string>;
41
41
  }
42
- export declare function twitchEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthTwitchConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
42
+ export declare function twitchEventHandler({ config, onSuccess, onError }: OAuthConfig<OAuthTwitchConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nitropack").NitroAppPlugin;
2
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { defineNitroPlugin } from "nitropack/runtime";
2
+ export default defineNitroPlugin((nitroApp) => {
3
+ if (process.env.NUXT_OAUTH_FACEBOOK_CLIENT_ID && process.env.NUXT_OAUTH_FACEBOOK_CLIENT_SECRET) {
4
+ nitroApp.hooks.hook("render:html", (html) => {
5
+ html.head.unshift(`
6
+ <script>
7
+ if (window.location.hash === "#_=_"){
8
+ history.replaceState
9
+ ? history.replaceState(null, null, window.location.href.split("#")[0])
10
+ : window.location.hash = "";
11
+ }
12
+ <\/script>
13
+ `);
14
+ });
15
+ }
16
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-auth-utils",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "Minimalist Auth module for Nuxt with SSR",
5
5
  "repository": "Atinux/nuxt-auth-utils",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "@iconify-json/simple-icons": "^1.1.99",
43
43
  "@nuxt/devtools": "latest",
44
44
  "@nuxt/eslint-config": "^0.3.8",
45
- "@nuxt/module-builder": "^0.5.5",
45
+ "@nuxt/module-builder": "^0.6.0",
46
46
  "@nuxt/schema": "^3.11.2",
47
47
  "@nuxt/test-utils": "^3.12.1",
48
48
  "@nuxt/ui": "^2.15.2",