@logto/nuxt 0.3.4 → 1.0.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.
- package/dist/module.d.mts +24 -0
- package/dist/module.d.ts +24 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/server/event-handler.mjs +13 -12
- package/dist/runtime/utils/constants.d.ts +1 -0
- package/dist/runtime/utils/constants.mjs +2 -1
- package/dist/runtime/utils/types.d.ts +23 -0
- package/package.json +2 -2
package/dist/module.d.mts
CHANGED
|
@@ -13,6 +13,14 @@ type LogtoModuleOptions = {
|
|
|
13
13
|
* @see {@link CookieConfig.cookieKey} for the default value.
|
|
14
14
|
*/
|
|
15
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;
|
|
16
24
|
/**
|
|
17
25
|
* If Logto should fetch from the [userinfo endpoint](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
|
|
18
26
|
* in the server side for the `event.context.logtoUser` property (used by `useLogtoUser` composable).
|
|
@@ -68,6 +76,21 @@ type LogtoRuntimeConfig = LogtoModuleOptions & {
|
|
|
68
76
|
* The secret used to encrypt the Logto cookie. It should be a random string.
|
|
69
77
|
*/
|
|
70
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;
|
|
71
94
|
} & Omit<LogtoConfig, 'appSecret'> & Required<Pick<LogtoConfig, 'appSecret'>>;
|
|
72
95
|
type LogtoRuntimeConfigInput = DeepPartial<LogtoRuntimeConfig>;
|
|
73
96
|
|
|
@@ -82,6 +105,7 @@ declare const defaults: Readonly<{
|
|
|
82
105
|
readonly appId: "<replace-with-logto-app-id>";
|
|
83
106
|
readonly appSecret: "<replace-with-logto-app-secret>";
|
|
84
107
|
readonly cookieEncryptionKey: "<replace-with-random-string>";
|
|
108
|
+
readonly customRedirectBaseUrl: "<replace-with-custom-redirect-base-url>";
|
|
85
109
|
}>;
|
|
86
110
|
|
|
87
111
|
declare const logtoModule: NuxtModule<LogtoRuntimeConfigInput>;
|
package/dist/module.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ type LogtoModuleOptions = {
|
|
|
13
13
|
* @see {@link CookieConfig.cookieKey} for the default value.
|
|
14
14
|
*/
|
|
15
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;
|
|
16
24
|
/**
|
|
17
25
|
* If Logto should fetch from the [userinfo endpoint](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
|
|
18
26
|
* in the server side for the `event.context.logtoUser` property (used by `useLogtoUser` composable).
|
|
@@ -68,6 +76,21 @@ type LogtoRuntimeConfig = LogtoModuleOptions & {
|
|
|
68
76
|
* The secret used to encrypt the Logto cookie. It should be a random string.
|
|
69
77
|
*/
|
|
70
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;
|
|
71
94
|
} & Omit<LogtoConfig, 'appSecret'> & Required<Pick<LogtoConfig, 'appSecret'>>;
|
|
72
95
|
type LogtoRuntimeConfigInput = DeepPartial<LogtoRuntimeConfig>;
|
|
73
96
|
|
|
@@ -82,6 +105,7 @@ declare const defaults: Readonly<{
|
|
|
82
105
|
readonly appId: "<replace-with-logto-app-id>";
|
|
83
106
|
readonly appSecret: "<replace-with-logto-app-secret>";
|
|
84
107
|
readonly cookieEncryptionKey: "<replace-with-random-string>";
|
|
108
|
+
readonly customRedirectBaseUrl: "<replace-with-custom-redirect-base-url>";
|
|
85
109
|
}>;
|
|
86
110
|
|
|
87
111
|
declare const logtoModule: NuxtModule<LogtoRuntimeConfigInput>;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -11,7 +11,8 @@ const defaults = Object.freeze({
|
|
|
11
11
|
endpoint: "<replace-with-logto-endpoint>",
|
|
12
12
|
appId: "<replace-with-logto-app-id>",
|
|
13
13
|
appSecret: "<replace-with-logto-app-secret>",
|
|
14
|
-
cookieEncryptionKey: "<replace-with-random-string>"
|
|
14
|
+
cookieEncryptionKey: "<replace-with-random-string>",
|
|
15
|
+
customRedirectBaseUrl: "<replace-with-custom-redirect-base-url>"
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
const logtoModule = defineNuxtModule({
|
|
@@ -9,10 +9,12 @@ export default defineEventHandler(async (event) => {
|
|
|
9
9
|
const {
|
|
10
10
|
cookieName,
|
|
11
11
|
cookieEncryptionKey,
|
|
12
|
+
cookieSecure,
|
|
12
13
|
fetchUserInfo,
|
|
13
14
|
pathnames,
|
|
14
15
|
postCallbackRedirectUri,
|
|
15
16
|
postLogoutRedirectUri,
|
|
17
|
+
customRedirectBaseUrl,
|
|
16
18
|
...clientConfig
|
|
17
19
|
} = logtoConfig;
|
|
18
20
|
const defaultValueKeys = Object.entries(defaults).filter(([key, value]) => logtoConfig[key] === value).map(([key]) => key);
|
|
@@ -23,18 +25,17 @@ export default defineEventHandler(async (event) => {
|
|
|
23
25
|
)}. Please replace them with your own values.`
|
|
24
26
|
);
|
|
25
27
|
}
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
);
|
|
28
|
+
const requestUrl = getRequestURL(event);
|
|
29
|
+
const url = customRedirectBaseUrl ? new URL(requestUrl.pathname + requestUrl.search + requestUrl.hash, customRedirectBaseUrl) : requestUrl;
|
|
30
|
+
const storage = new CookieStorage({
|
|
31
|
+
cookieKey: cookieName,
|
|
32
|
+
encryptionKey: cookieEncryptionKey,
|
|
33
|
+
isSecure: cookieSecure,
|
|
34
|
+
getCookie: (name) => getCookie(event, name),
|
|
35
|
+
setCookie: (name, value, options) => {
|
|
36
|
+
setCookie(event, name, value, options);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
38
39
|
await storage.init();
|
|
39
40
|
const logto = new LogtoClient(clientConfig, {
|
|
40
41
|
navigate: async (url2) => {
|
|
@@ -9,4 +9,5 @@ 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>";
|
|
12
13
|
}>;
|
|
@@ -6,5 +6,6 @@ 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>"
|
|
9
|
+
cookieEncryptionKey: "<replace-with-random-string>",
|
|
10
|
+
customRedirectBaseUrl: "<replace-with-custom-redirect-base-url>"
|
|
10
11
|
});
|
|
@@ -9,6 +9,14 @@ type LogtoModuleOptions = {
|
|
|
9
9
|
* @see {@link CookieConfig.cookieKey} for the default value.
|
|
10
10
|
*/
|
|
11
11
|
cookieName?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the Logto cookie should be secure.
|
|
14
|
+
*
|
|
15
|
+
* Set this to `true` if you are using https.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link CookieConfig.isSecure}
|
|
18
|
+
*/
|
|
19
|
+
cookieSecure?: boolean;
|
|
12
20
|
/**
|
|
13
21
|
* If Logto should fetch from the [userinfo endpoint](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
|
|
14
22
|
* in the server side for the `event.context.logtoUser` property (used by `useLogtoUser` composable).
|
|
@@ -64,6 +72,21 @@ export type LogtoRuntimeConfig = LogtoModuleOptions & {
|
|
|
64
72
|
* The secret used to encrypt the Logto cookie. It should be a random string.
|
|
65
73
|
*/
|
|
66
74
|
cookieEncryptionKey: string;
|
|
75
|
+
/**
|
|
76
|
+
* Custom base URL for redirects
|
|
77
|
+
*
|
|
78
|
+
* This URL is used as the base for generating redirect and callback URLs.
|
|
79
|
+
* It's particularly useful in environments where the application is behind
|
|
80
|
+
* a proxy or where URLs are rewritten.
|
|
81
|
+
*
|
|
82
|
+
* If set, this value will be used instead of the automatically detected URL.
|
|
83
|
+
* If not set, the system will use the URL obtained from `getRequestURL`.
|
|
84
|
+
*
|
|
85
|
+
* Example: 'https://your-public-facing-domain.com'
|
|
86
|
+
*
|
|
87
|
+
* Note: Provide only the base URL without paths or query parameters.
|
|
88
|
+
*/
|
|
89
|
+
customRedirectBaseUrl: string;
|
|
67
90
|
} & Omit<LogtoConfig, 'appSecret'> & Required<Pick<LogtoConfig, 'appSecret'>>;
|
|
68
91
|
export type LogtoRuntimeConfigInput = DeepPartial<LogtoRuntimeConfig>;
|
|
69
92
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@nuxt/kit": "^3.10.2",
|
|
46
46
|
"@silverhand/essentials": "^2.8.7",
|
|
47
47
|
"defu": "^6.1.4",
|
|
48
|
-
"@logto/node": "^2.5.
|
|
48
|
+
"@logto/node": "^2.5.7"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"precommit": "lint-staged",
|