@logto/nuxt 1.2.5 → 1.2.7

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.
@@ -0,0 +1,10 @@
1
+ import { type NuxtModule } from 'nuxt/schema';
2
+ import { type LogtoRuntimeConfigInput } from './runtime/utils/types';
3
+ export * from '@logto/node';
4
+ export { default as LogtoNodeClient } from '@logto/node';
5
+ export * from './runtime/utils/types';
6
+ export * from './runtime/utils/constants';
7
+ export * from './runtime/utils/handler';
8
+ declare const logtoModule: NuxtModule<LogtoRuntimeConfigInput>;
9
+ export default logtoModule;
10
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAA2B,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAG9F,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AAExC,QAAA,MAAM,WAAW,EAAE,UAAU,CAAC,uBAAuB,CA0CnD,CAAC;AAEH,eAAe,WAAW,CAAC"}
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@logto/nuxt",
3
3
  "configKey": "logto",
4
- "version": "1.2.5",
4
+ "version": "1.2.7",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "unknown"
@@ -0,0 +1,21 @@
1
+ import type LogtoClient from '@logto/node';
2
+ /**
3
+ * Get the Logto client instance in the current context. Returns `undefined` if the client is not
4
+ * available.
5
+ *
6
+ * Note: This composable only works in the server side and relies on the SSR context which is
7
+ * filled by the Logto event handler.
8
+ *
9
+ * @returns The Logto client instance if available, otherwise `undefined`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const client = useLogtoClient();
14
+ *
15
+ * if (client) {
16
+ * const token = await client.getAccessToken();
17
+ * }
18
+ * ```
19
+ */
20
+ export default function useLogtoClient(): LogtoClient | undefined;
21
+ //# sourceMappingURL=use-logto-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-logto-client.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/use-logto-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,IAAI,WAAW,GAAG,SAAS,CAKhE"}
@@ -0,0 +1,21 @@
1
+ import type { UserInfoResponse } from '@logto/node';
2
+ /**
3
+ * Get the Logto user information. If the user is not signed in, this composable will return
4
+ * `undefined`.
5
+ *
6
+ * Note: This composable relies on the SSR context which is filled by the Logto event handler. Once
7
+ * the user is signed in, the user information will be available in both the server and client side.
8
+ *
9
+ * @returns The user information if the user is signed in, otherwise `undefined`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const user = useLogtoUser();
14
+ *
15
+ * if (user) {
16
+ * console.log('User is signed in:', user); // { sub: '123', ... }
17
+ * }
18
+ * ```
19
+ */
20
+ export default function useLogtoUser(): UserInfoResponse | undefined;
21
+ //# sourceMappingURL=use-logto-user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-logto-user.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/use-logto-user.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,iCAMnC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
2
+ export default _default;
3
+ //# sourceMappingURL=event-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-handler.d.ts","sourceRoot":"","sources":["../../../src/runtime/server/event-handler.ts"],"names":[],"mappings":";AAMA,wBAGG"}
@@ -0,0 +1,13 @@
1
+ /** The keys used to store the Logto state in `useState()`. */
2
+ export declare enum LogtoStateKey {
3
+ /** The key used to store the Logto user information. */
4
+ User = "logto.user"
5
+ }
6
+ /** The default Logto runtime configuration values that should be replaced with your own values. */
7
+ export declare const defaults: Readonly<{
8
+ readonly endpoint: "<replace-with-logto-endpoint>";
9
+ readonly appId: "<replace-with-logto-app-id>";
10
+ readonly appSecret: "<replace-with-logto-app-secret>";
11
+ readonly cookieEncryptionKey: "<replace-with-random-string>";
12
+ }>;
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/constants.ts"],"names":[],"mappings":"AAEA,8DAA8D;AAC9D,oBAAY,aAAa;IACvB,wDAAwD;IACxD,IAAI,eAAe;CACpB;AAED,mGAAmG;AACnG,eAAO,MAAM,QAAQ;;;;;EAKwB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type H3Event } from 'h3';
2
+ import type { RuntimeConfig } from 'nuxt/schema';
3
+ export declare const logtoEventHandler: (event: H3Event, config: RuntimeConfig) => Promise<void>;
4
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAqD,MAAM,IAAI,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,eAAO,MAAM,iBAAiB,UAAiB,OAAO,UAAU,aAAa,kBAwF5E,CAAC"}
@@ -0,0 +1,106 @@
1
+ import type LogtoClient from '@logto/node';
2
+ import type { LogtoConfig, SignInOptions, IdTokenClaims, UserInfoResponse } from '@logto/node';
3
+ declare module 'h3' {
4
+ interface H3EventContext {
5
+ logtoUser: UserInfoResponse | IdTokenClaims | undefined;
6
+ logtoClient: LogtoClient;
7
+ }
8
+ }
9
+ type DeepPartial<T> = T extends Record<string, unknown> ? {
10
+ [P in keyof T]?: DeepPartial<T[P]>;
11
+ } : T;
12
+ type LogtoModuleOptions = {
13
+ /**
14
+ * The name to use when storing the Logto cookie.
15
+ *
16
+ * @see {@link CookieConfig.cookieKey} for the default value.
17
+ */
18
+ cookieName?: string;
19
+ /**
20
+ * Whether the Logto cookie should be secure.
21
+ *
22
+ * Set this to `true` if you are using https.
23
+ *
24
+ * @see {@link CookieConfig.isSecure}
25
+ */
26
+ cookieSecure?: boolean;
27
+ /**
28
+ * If Logto should fetch from the [userinfo endpoint](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
29
+ * in the server side for the `event.context.logtoUser` property (used by `useLogtoUser` composable).
30
+ *
31
+ * This is useful when you need to fetch additional claims like `custom_data`.
32
+ */
33
+ fetchUserInfo: boolean;
34
+ /**
35
+ * The URI to redirect to after a successful sign-in callback.
36
+ *
37
+ * This is NOT the redirect URI used in Logto's configuration. This is the URI that the user will be
38
+ * redirected to after the sign-in callback is handled by the server.
39
+ *
40
+ * @default '/'
41
+ */
42
+ postCallbackRedirectUri: string;
43
+ /**
44
+ * The URI to redirect to after a successful sign-out.
45
+ *
46
+ * This is the post sign-out redirect URI used in Logto's configuration.
47
+ *
48
+ * @default '/'
49
+ */
50
+ postLogoutRedirectUri: string;
51
+ /**
52
+ * Pathnames for the sign-in, sign-out, and callback URIs. They will be handled by the Logto
53
+ * event handler.
54
+ */
55
+ pathnames: {
56
+ /**
57
+ * The URI for initiating the sign-in process.
58
+ *
59
+ * @default '/sign-in'
60
+ */
61
+ signIn: string;
62
+ /**
63
+ * The URI for initiating the sign-out process.
64
+ *
65
+ * @default '/sign-out'
66
+ */
67
+ signOut: string;
68
+ /**
69
+ * The URI for handling the sign-in callback.
70
+ *
71
+ * @default '/callback'
72
+ */
73
+ callback: string;
74
+ };
75
+ /**
76
+ * The options for the sign-in process.
77
+ *
78
+ * @see https://docs.logto.io/docs/references/openid-connect/authentication-parameters
79
+ */
80
+ signInOptions?: Omit<SignInOptions, 'redirectUri' | 'postRedirectUri'>;
81
+ };
82
+ /** The full runtime configuration for the Logto module. */
83
+ export type LogtoRuntimeConfig = LogtoModuleOptions & {
84
+ /**
85
+ * The secret used to encrypt the Logto cookie. It should be a random string.
86
+ */
87
+ cookieEncryptionKey: string;
88
+ /**
89
+ * Custom base URL for redirects
90
+ *
91
+ * This URL is used as the base for generating redirect and callback URLs.
92
+ * It's particularly useful in environments where the application is behind
93
+ * a proxy or where URLs are rewritten.
94
+ *
95
+ * If set, this value will be used instead of the automatically detected URL.
96
+ * If not set, the system will use the URL obtained from `getRequestURL`.
97
+ *
98
+ * Example: 'https://your-public-facing-domain.com'
99
+ *
100
+ * Note: Provide only the base URL without paths or query parameters.
101
+ */
102
+ customRedirectBaseUrl: string;
103
+ } & Omit<LogtoConfig, 'appSecret'> & Required<Pick<LogtoConfig, 'appSecret'>>;
104
+ export type LogtoRuntimeConfigInput = DeepPartial<LogtoRuntimeConfig>;
105
+ export {};
106
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,QAAQ,IAAI,CAAC;IAElB,UAAU,cAAc;QACtB,SAAS,EAAE,gBAAgB,GAAG,aAAa,GAAG,SAAS,CAAC;QACxD,WAAW,EAAE,WAAW,CAAC;KAC1B;CACF;AAED,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnD;KACG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACnC,GACD,CAAC,CAAC;AAEN,KAAK,kBAAkB,GAAG;IACxB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB;;;;;;;OAOG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;;;;OAMG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,SAAS,EAAE;QACT;;;;WAIG;QACH,MAAM,EAAE,MAAM,CAAC;QACf;;;;WAIG;QACH,OAAO,EAAE,MAAM,CAAC;QAChB;;;;WAIG;QACH,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF;;;;OAIG;IACH,aAAa,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,iBAAiB,CAAC,CAAC;CACxE,CAAC;AAEF,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG;IACpD;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;;OAaG;IACH,qBAAqB,EAAE,MAAM,CAAC;CAC/B,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,GAChC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AAE3C,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@logto/nuxt",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
7
+ "types": "./dist/module.d.mts",
7
8
  "import": "./dist/module.mjs"
8
9
  }
9
10
  },
11
+ "types": "./dist/module.d.mts",
10
12
  "files": [
11
13
  "dist"
12
14
  ],
@@ -24,7 +26,7 @@
24
26
  "@vue/test-utils": "^2.4.4",
25
27
  "eslint": "^8.57.0",
26
28
  "h3": "^1.13.0",
27
- "happy-dom": "^16.0.0",
29
+ "happy-dom": "^20.0.8",
28
30
  "lint-staged": "^15.0.0",
29
31
  "nuxt": "^3.17.2",
30
32
  "prettier": "^3.0.0",
@@ -43,13 +45,13 @@
43
45
  "@nuxt/kit": "^3.17.2",
44
46
  "@silverhand/essentials": "^2.9.2",
45
47
  "defu": "^6.1.4",
46
- "@logto/node": "^3.1.5"
48
+ "@logto/node": "^3.1.7"
47
49
  },
48
50
  "scripts": {
49
51
  "precommit": "lint-staged",
50
52
  "dev": "nuxi dev playground",
51
53
  "dev:prepare": "nuxt-module-build prepare && nuxi prepare playground",
52
- "build": "nuxt-module-build prepare && nuxt-module-build build",
54
+ "build": "nuxt-module-build prepare && nuxt-module-build build && tsc -p tsconfig.build.json",
53
55
  "test": "vitest",
54
56
  "test:coverage": "vitest --coverage",
55
57
  "check": "tsc --noEmit",