@logto/nuxt 1.0.1 → 1.1.4

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.d.mts CHANGED
@@ -1,113 +1,10 @@
1
1
  import { NuxtModule } from 'nuxt/schema';
2
- import { LogtoConfig } from '@logto/node';
2
+ import { LogtoRuntimeConfigInput } from '../dist/runtime/utils/types.js';
3
+ export * from '../dist/runtime/utils/types.js';
3
4
  export * from '@logto/node';
4
5
  export { default as LogtoNodeClient } from '@logto/node';
5
-
6
- type DeepPartial<T> = T extends Record<string, unknown> ? {
7
- [P in keyof T]?: DeepPartial<T[P]>;
8
- } : T;
9
- type LogtoModuleOptions = {
10
- /**
11
- * The name to use when storing the Logto cookie.
12
- *
13
- * @see {@link CookieConfig.cookieKey} for the default value.
14
- */
15
- cookieName?: string;
16
- /**
17
- * Whether the Logto cookie should be secure.
18
- *
19
- * Set this to `true` if you are using https.
20
- *
21
- * @see {@link CookieConfig.isSecure}
22
- */
23
- cookieSecure?: boolean;
24
- /**
25
- * If Logto should fetch from the [userinfo endpoint](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
26
- * in the server side for the `event.context.logtoUser` property (used by `useLogtoUser` composable).
27
- *
28
- * This is useful when you need to fetch additional claims like `custom_data`.
29
- */
30
- fetchUserInfo: boolean;
31
- /**
32
- * The URI to redirect to after a successful sign-in callback.
33
- *
34
- * This is NOT the redirect URI used in Logto's configuration. This is the URI that the user will be
35
- * redirected to after the sign-in callback is handled by the server.
36
- *
37
- * @default '/'
38
- */
39
- postCallbackRedirectUri: string;
40
- /**
41
- * The URI to redirect to after a successful sign-out.
42
- *
43
- * This is the post sign-out redirect URI used in Logto's configuration.
44
- *
45
- * @default '/'
46
- */
47
- postLogoutRedirectUri: string;
48
- /**
49
- * Pathnames for the sign-in, sign-out, and callback URIs. They will be handled by the Logto
50
- * event handler.
51
- */
52
- pathnames: {
53
- /**
54
- * The URI for initiating the sign-in process.
55
- *
56
- * @default '/sign-in'
57
- */
58
- signIn: string;
59
- /**
60
- * The URI for initiating the sign-out process.
61
- *
62
- * @default '/sign-out'
63
- */
64
- signOut: string;
65
- /**
66
- * The URI for handling the sign-in callback.
67
- *
68
- * @default '/callback'
69
- */
70
- callback: string;
71
- };
72
- };
73
- /** The full runtime configuration for the Logto module. */
74
- type LogtoRuntimeConfig = LogtoModuleOptions & {
75
- /**
76
- * The secret used to encrypt the Logto cookie. It should be a random string.
77
- */
78
- cookieEncryptionKey: string;
79
- /**
80
- * Custom base URL for redirects
81
- *
82
- * This URL is used as the base for generating redirect and callback URLs.
83
- * It's particularly useful in environments where the application is behind
84
- * a proxy or where URLs are rewritten.
85
- *
86
- * If set, this value will be used instead of the automatically detected URL.
87
- * If not set, the system will use the URL obtained from `getRequestURL`.
88
- *
89
- * Example: 'https://your-public-facing-domain.com'
90
- *
91
- * Note: Provide only the base URL without paths or query parameters.
92
- */
93
- customRedirectBaseUrl: string;
94
- } & Omit<LogtoConfig, 'appSecret'> & Required<Pick<LogtoConfig, 'appSecret'>>;
95
- type LogtoRuntimeConfigInput = DeepPartial<LogtoRuntimeConfig>;
96
-
97
- /** The keys used to store the Logto state in `useState()`. */
98
- declare enum LogtoStateKey {
99
- /** The key used to store the Logto user information. */
100
- User = "logto.user"
101
- }
102
- /** The default Logto runtime configuration values that should be replaced with your own values. */
103
- declare const defaults: Readonly<{
104
- readonly endpoint: "<replace-with-logto-endpoint>";
105
- readonly appId: "<replace-with-logto-app-id>";
106
- readonly appSecret: "<replace-with-logto-app-secret>";
107
- readonly cookieEncryptionKey: "<replace-with-random-string>";
108
- readonly customRedirectBaseUrl: "<replace-with-custom-redirect-base-url>";
109
- }>;
6
+ export * from '../dist/runtime/utils/constants.js';
110
7
 
111
8
  declare const logtoModule: NuxtModule<LogtoRuntimeConfigInput>;
112
9
 
113
- export { type LogtoRuntimeConfig, type LogtoRuntimeConfigInput, LogtoStateKey, logtoModule as default, defaults };
10
+ export { logtoModule as default };
package/dist/module.d.ts CHANGED
@@ -1,113 +1,10 @@
1
1
  import { NuxtModule } from 'nuxt/schema';
2
- import { LogtoConfig } from '@logto/node';
2
+ import { LogtoRuntimeConfigInput } from '../dist/runtime/utils/types.js';
3
+ export * from '../dist/runtime/utils/types.js';
3
4
  export * from '@logto/node';
4
5
  export { default as LogtoNodeClient } from '@logto/node';
5
-
6
- type DeepPartial<T> = T extends Record<string, unknown> ? {
7
- [P in keyof T]?: DeepPartial<T[P]>;
8
- } : T;
9
- type LogtoModuleOptions = {
10
- /**
11
- * The name to use when storing the Logto cookie.
12
- *
13
- * @see {@link CookieConfig.cookieKey} for the default value.
14
- */
15
- cookieName?: string;
16
- /**
17
- * Whether the Logto cookie should be secure.
18
- *
19
- * Set this to `true` if you are using https.
20
- *
21
- * @see {@link CookieConfig.isSecure}
22
- */
23
- cookieSecure?: boolean;
24
- /**
25
- * If Logto should fetch from the [userinfo endpoint](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
26
- * in the server side for the `event.context.logtoUser` property (used by `useLogtoUser` composable).
27
- *
28
- * This is useful when you need to fetch additional claims like `custom_data`.
29
- */
30
- fetchUserInfo: boolean;
31
- /**
32
- * The URI to redirect to after a successful sign-in callback.
33
- *
34
- * This is NOT the redirect URI used in Logto's configuration. This is the URI that the user will be
35
- * redirected to after the sign-in callback is handled by the server.
36
- *
37
- * @default '/'
38
- */
39
- postCallbackRedirectUri: string;
40
- /**
41
- * The URI to redirect to after a successful sign-out.
42
- *
43
- * This is the post sign-out redirect URI used in Logto's configuration.
44
- *
45
- * @default '/'
46
- */
47
- postLogoutRedirectUri: string;
48
- /**
49
- * Pathnames for the sign-in, sign-out, and callback URIs. They will be handled by the Logto
50
- * event handler.
51
- */
52
- pathnames: {
53
- /**
54
- * The URI for initiating the sign-in process.
55
- *
56
- * @default '/sign-in'
57
- */
58
- signIn: string;
59
- /**
60
- * The URI for initiating the sign-out process.
61
- *
62
- * @default '/sign-out'
63
- */
64
- signOut: string;
65
- /**
66
- * The URI for handling the sign-in callback.
67
- *
68
- * @default '/callback'
69
- */
70
- callback: string;
71
- };
72
- };
73
- /** The full runtime configuration for the Logto module. */
74
- type LogtoRuntimeConfig = LogtoModuleOptions & {
75
- /**
76
- * The secret used to encrypt the Logto cookie. It should be a random string.
77
- */
78
- cookieEncryptionKey: string;
79
- /**
80
- * Custom base URL for redirects
81
- *
82
- * This URL is used as the base for generating redirect and callback URLs.
83
- * It's particularly useful in environments where the application is behind
84
- * a proxy or where URLs are rewritten.
85
- *
86
- * If set, this value will be used instead of the automatically detected URL.
87
- * If not set, the system will use the URL obtained from `getRequestURL`.
88
- *
89
- * Example: 'https://your-public-facing-domain.com'
90
- *
91
- * Note: Provide only the base URL without paths or query parameters.
92
- */
93
- customRedirectBaseUrl: string;
94
- } & Omit<LogtoConfig, 'appSecret'> & Required<Pick<LogtoConfig, 'appSecret'>>;
95
- type LogtoRuntimeConfigInput = DeepPartial<LogtoRuntimeConfig>;
96
-
97
- /** The keys used to store the Logto state in `useState()`. */
98
- declare enum LogtoStateKey {
99
- /** The key used to store the Logto user information. */
100
- User = "logto.user"
101
- }
102
- /** The default Logto runtime configuration values that should be replaced with your own values. */
103
- declare const defaults: Readonly<{
104
- readonly endpoint: "<replace-with-logto-endpoint>";
105
- readonly appId: "<replace-with-logto-app-id>";
106
- readonly appSecret: "<replace-with-logto-app-secret>";
107
- readonly cookieEncryptionKey: "<replace-with-random-string>";
108
- readonly customRedirectBaseUrl: "<replace-with-custom-redirect-base-url>";
109
- }>;
6
+ export * from '../dist/runtime/utils/constants.js';
110
7
 
111
8
  declare const logtoModule: NuxtModule<LogtoRuntimeConfigInput>;
112
9
 
113
- export { type LogtoRuntimeConfig, type LogtoRuntimeConfigInput, LogtoStateKey, logtoModule as default, defaults };
10
+ export { logtoModule as default };
package/dist/module.json CHANGED
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "name": "@logto/nuxt",
3
3
  "configKey": "logto",
4
- "version": "1.0.1"
4
+ "version": "1.1.4",
5
+ "builder": {
6
+ "@nuxt/module-builder": "0.8.4",
7
+ "unbuild": "unknown"
8
+ }
5
9
  }
package/dist/module.mjs CHANGED
@@ -1,19 +1,10 @@
1
1
  import { defineNuxtModule, createResolver, addServerHandler, addImportsDir } from '@nuxt/kit';
2
2
  import { defu } from 'defu';
3
+ import { defaults } from '../dist/runtime/utils/constants.js';
4
+ export * from '../dist/runtime/utils/constants.js';
3
5
  export * from '@logto/node';
4
6
  export { default as LogtoNodeClient } from '@logto/node';
5
-
6
- var LogtoStateKey = /* @__PURE__ */ ((LogtoStateKey2) => {
7
- LogtoStateKey2["User"] = "logto.user";
8
- return LogtoStateKey2;
9
- })(LogtoStateKey || {});
10
- const defaults = Object.freeze({
11
- endpoint: "<replace-with-logto-endpoint>",
12
- appId: "<replace-with-logto-app-id>",
13
- appSecret: "<replace-with-logto-app-secret>",
14
- cookieEncryptionKey: "<replace-with-random-string>",
15
- customRedirectBaseUrl: "<replace-with-custom-redirect-base-url>"
16
- });
7
+ export * from '../dist/runtime/utils/types.js';
17
8
 
18
9
  const logtoModule = defineNuxtModule({
19
10
  meta: {
@@ -45,4 +36,4 @@ const logtoModule = defineNuxtModule({
45
36
  }
46
37
  });
47
38
 
48
- export { LogtoStateKey, logtoModule as default, defaults };
39
+ export { logtoModule as default };
@@ -1,4 +1,4 @@
1
- import { LogtoStateKey } from "../utils/constants.mjs";
1
+ import { LogtoStateKey } from "../utils/constants.js";
2
2
  import { shallowRef as shallowReference, useNuxtApp, useState } from "#imports";
3
3
  export default function useLogtoUser() {
4
4
  const nuxtApp = useNuxtApp();
@@ -1,7 +1,7 @@
1
1
  import LogtoClient, { CookieStorage } from "@logto/node";
2
2
  import { trySafe } from "@silverhand/essentials";
3
3
  import { defineEventHandler, getRequestURL, getCookie, setCookie, sendRedirect } from "h3";
4
- import { defaults } from "../utils/constants.mjs";
4
+ import { defaults } from "../utils/constants.js";
5
5
  import { useRuntimeConfig } from "#imports";
6
6
  export default defineEventHandler(async (event) => {
7
7
  const config = useRuntimeConfig(event);
@@ -15,6 +15,7 @@ export default defineEventHandler(async (event) => {
15
15
  postCallbackRedirectUri,
16
16
  postLogoutRedirectUri,
17
17
  customRedirectBaseUrl,
18
+ signInOptions,
18
19
  ...clientConfig
19
20
  } = logtoConfig;
20
21
  const defaultValueKeys = Object.entries(defaults).filter(([key, value]) => logtoConfig[key] === value).map(([key]) => key);
@@ -44,7 +45,10 @@ export default defineEventHandler(async (event) => {
44
45
  storage
45
46
  });
46
47
  if (url.pathname === pathnames.signIn) {
47
- await logto.signIn(new URL(pathnames.callback, url).href);
48
+ await logto.signIn({
49
+ ...signInOptions,
50
+ redirectUri: new URL(pathnames.callback, url).href
51
+ });
48
52
  return;
49
53
  }
50
54
  if (url.pathname === pathnames.signOut) {
@@ -9,5 +9,4 @@ export declare const defaults: Readonly<{
9
9
  readonly appId: "<replace-with-logto-app-id>";
10
10
  readonly appSecret: "<replace-with-logto-app-secret>";
11
11
  readonly cookieEncryptionKey: "<replace-with-random-string>";
12
- readonly customRedirectBaseUrl: "<replace-with-custom-redirect-base-url>";
13
12
  }>;
@@ -6,6 +6,5 @@ export const defaults = Object.freeze({
6
6
  endpoint: "<replace-with-logto-endpoint>",
7
7
  appId: "<replace-with-logto-app-id>",
8
8
  appSecret: "<replace-with-logto-app-secret>",
9
- cookieEncryptionKey: "<replace-with-random-string>",
10
- customRedirectBaseUrl: "<replace-with-custom-redirect-base-url>"
9
+ cookieEncryptionKey: "<replace-with-random-string>"
11
10
  });
@@ -1,4 +1,4 @@
1
- import type { LogtoConfig } from '@logto/node';
1
+ import type { LogtoConfig, SignInOptions } from '@logto/node';
2
2
  type DeepPartial<T> = T extends Record<string, unknown> ? {
3
3
  [P in keyof T]?: DeepPartial<T[P]>;
4
4
  } : T;
@@ -65,6 +65,12 @@ type LogtoModuleOptions = {
65
65
  */
66
66
  callback: string;
67
67
  };
68
+ /**
69
+ * The options for the sign-in process.
70
+ *
71
+ * @see https://docs.logto.io/docs/references/openid-connect/authentication-parameters
72
+ */
73
+ signInOptions?: Omit<SignInOptions, 'redirectUri' | 'postRedirectUri'>;
68
74
  };
69
75
  /** The full runtime configuration for the Logto module. */
70
76
  export type LogtoRuntimeConfig = LogtoModuleOptions & {
package/dist/types.d.mts CHANGED
@@ -1,25 +1,7 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
1
2
 
2
- import type { ModuleOptions, ModuleHooks, RuntimeModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module.js'
3
+ import type { default as Module } from './module.js'
3
4
 
4
- declare module '#app' {
5
- interface RuntimeNuxtHooks extends RuntimeModuleHooks, ModuleRuntimeHooks {}
6
- }
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
7
6
 
8
- declare module '@nuxt/schema' {
9
- interface NuxtConfig { ['logto']?: Partial<ModuleOptions> }
10
- interface NuxtOptions { ['logto']?: ModuleOptions }
11
- interface NuxtHooks extends ModuleHooks {}
12
- interface RuntimeConfig extends ModuleRuntimeConfig {}
13
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
14
- }
15
-
16
- declare module 'nuxt/schema' {
17
- interface NuxtConfig { ['logto']?: Partial<ModuleOptions> }
18
- interface NuxtOptions { ['logto']?: ModuleOptions }
19
- interface NuxtHooks extends ModuleHooks {}
20
- interface RuntimeConfig extends ModuleRuntimeConfig {}
21
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
22
- }
23
-
24
-
25
- export type { LogtoNodeClient } from './module.js'
7
+ export { type LogtoNodeClient } from './module.js'
package/dist/types.d.ts CHANGED
@@ -1,25 +1,7 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
1
2
 
2
- import type { ModuleOptions, ModuleHooks, RuntimeModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module'
3
+ import type { default as Module } from './module'
3
4
 
4
- declare module '#app' {
5
- interface RuntimeNuxtHooks extends RuntimeModuleHooks, ModuleRuntimeHooks {}
6
- }
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
7
6
 
8
- declare module '@nuxt/schema' {
9
- interface NuxtConfig { ['logto']?: Partial<ModuleOptions> }
10
- interface NuxtOptions { ['logto']?: ModuleOptions }
11
- interface NuxtHooks extends ModuleHooks {}
12
- interface RuntimeConfig extends ModuleRuntimeConfig {}
13
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
14
- }
15
-
16
- declare module 'nuxt/schema' {
17
- interface NuxtConfig { ['logto']?: Partial<ModuleOptions> }
18
- interface NuxtOptions { ['logto']?: ModuleOptions }
19
- interface NuxtHooks extends ModuleHooks {}
20
- interface RuntimeConfig extends ModuleRuntimeConfig {}
21
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
22
- }
23
-
24
-
25
- export type { LogtoNodeClient } from './module'
7
+ export { type LogtoNodeClient } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/nuxt",
3
- "version": "1.0.1",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -19,16 +19,16 @@
19
19
  "directory": "packages/nuxt"
20
20
  },
21
21
  "devDependencies": {
22
- "@nuxt/module-builder": "^0.5.5",
22
+ "@nuxt/module-builder": "^0.8.0",
23
23
  "@nuxt/test-utils": "^3.12.1",
24
24
  "@silverhand/eslint-config": "^6.0.1",
25
25
  "@vitest/coverage-v8": "^1.6.0",
26
26
  "@vue/test-utils": "^2.4.4",
27
27
  "eslint": "^8.57.0",
28
28
  "h3": "^1.11.1",
29
- "happy-dom": "^14.0.0",
29
+ "happy-dom": "^15.10.2",
30
30
  "lint-staged": "^15.0.0",
31
- "nuxt": "^3.11.2",
31
+ "nuxt": "^3.12.4",
32
32
  "prettier": "^3.0.0",
33
33
  "typescript": "^5.3.3",
34
34
  "vitest": "^1.6.0",
@@ -43,9 +43,9 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@nuxt/kit": "^3.10.2",
46
- "@silverhand/essentials": "^2.8.7",
46
+ "@silverhand/essentials": "^2.9.2",
47
47
  "defu": "^6.1.4",
48
- "@logto/node": "^2.5.8"
48
+ "@logto/node": "^3.0.3"
49
49
  },
50
50
  "scripts": {
51
51
  "precommit": "lint-staged",
File without changes