@authup/client-web-nuxt 1.0.0-beta.70 → 1.0.0-beta.71
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/README.md
CHANGED
|
@@ -56,7 +56,7 @@ export default defineNuxtConfig({
|
|
|
56
56
|
});
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Every option except `serverApiURL` lands in the public `runtimeConfig.public.authup`, so `NUXT_PUBLIC_AUTHUP_API_URL` overrides `apiURL` at runtime. `serverApiURL` goes to the private `runtimeConfig.authup` and is overridden with `NUXT_AUTHUP_SERVER_API_URL`.
|
|
59
|
+
Every option except `serverApiURL` lands in the public `runtimeConfig.public.authup`, so `NUXT_PUBLIC_AUTHUP_API_URL` overrides `apiURL` at runtime. `serverApiURL` goes to the private `runtimeConfig.authup` and is overridden with `NUXT_AUTHUP_SERVER_API_URL`. It only changes where the server render sends its requests: every URL the kit's client derives from the API URL (identity provider links, the OAuth2 endpoints) keeps the public one, since hydration does not correct a rendered `href`. A `buildAuthorizeURL` call takes its base from you, so pass it the public `apiURL`.
|
|
60
60
|
|
|
61
61
|
### Install vuecs after the kit
|
|
62
62
|
|
|
@@ -134,7 +134,7 @@ Set under the `authup` key of `nuxt.config`:
|
|
|
134
134
|
| Option | Type | Default | Description |
|
|
135
135
|
|---|---|---|---|
|
|
136
136
|
| `apiURL` | `string` | `http://localhost:3001` | API URL for the browser, and for the server when nothing more specific is set. |
|
|
137
|
-
| `serverApiURL` | `string` | `apiURL` |
|
|
137
|
+
| `serverApiURL` | `string` | `apiURL` | Address the server render dials. URLs the kit renders keep the public API URL. Private runtime config only. |
|
|
138
138
|
| `apiURLRuntimeKey` | `string` | none | Path into the runtime config to read the API URL from: the whole runtime config on the server, the public one in the browser. `serverApiURL` still wins on the server. |
|
|
139
139
|
| `cookieDomain` | `string` | host only | `Domain` attribute of the session cookies. `127.0.0.1` is written as `localhost`. |
|
|
140
140
|
| `cookieDomainRuntimeKey` | `string` | none | Path into the public runtime config to read the cookie domain from. |
|
package/dist/module.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HTTPClientInput } from '@authup/client-web-kit';
|
|
2
|
+
import type { RuntimeConfig } from 'nuxt/schema';
|
|
3
|
+
export type HTTPClientOptions = {
|
|
4
|
+
baseURL: string;
|
|
5
|
+
httpClient?: HTTPClientInput;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The kit's base url is the PUBLIC api url on both sides, because everything
|
|
9
|
+
* derived from it is user-facing: the identity provider buttons, the absolute
|
|
10
|
+
* OAuth2 endpoints and hapic's error messages. A server render only DIALS
|
|
11
|
+
* the server url, through a rebased transport, so a rendered href never
|
|
12
|
+
* names an address the browser cannot reach (hydration does not correct
|
|
13
|
+
* attributes). A function, so the kit gets a new client per consumer.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildHTTPClientOptions(runtimeConfig: RuntimeConfig, isServer: boolean): HTTPClientOptions;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { API_URL_DEFAULT, Client, createRebasedTransport } from "@authup/core-http-kit";
|
|
2
|
+
import { getPathValue } from "pathtrace";
|
|
3
|
+
function readPublicApiURL(runtimeConfig) {
|
|
4
|
+
const options = runtimeConfig.public.authup;
|
|
5
|
+
let url;
|
|
6
|
+
if (options.apiURL) {
|
|
7
|
+
url = options.apiURL;
|
|
8
|
+
}
|
|
9
|
+
if (options.apiURLRuntimeKey) {
|
|
10
|
+
const pathValue = getPathValue(runtimeConfig.public, options.apiURLRuntimeKey);
|
|
11
|
+
if (typeof pathValue === "string") {
|
|
12
|
+
url = pathValue;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return url || API_URL_DEFAULT;
|
|
16
|
+
}
|
|
17
|
+
function readServerApiURL(runtimeConfig) {
|
|
18
|
+
const options = runtimeConfig.public.authup;
|
|
19
|
+
let url;
|
|
20
|
+
if (options.apiURLRuntimeKey) {
|
|
21
|
+
const pathValue = getPathValue(runtimeConfig, options.apiURLRuntimeKey);
|
|
22
|
+
if (typeof pathValue === "string") {
|
|
23
|
+
url = pathValue;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const serverOptions = runtimeConfig.authup;
|
|
27
|
+
if (serverOptions?.serverApiURL) {
|
|
28
|
+
url = serverOptions.serverApiURL;
|
|
29
|
+
}
|
|
30
|
+
return url;
|
|
31
|
+
}
|
|
32
|
+
export function buildHTTPClientOptions(runtimeConfig, isServer) {
|
|
33
|
+
const baseURL = readPublicApiURL(runtimeConfig);
|
|
34
|
+
if (!isServer) {
|
|
35
|
+
return { baseURL };
|
|
36
|
+
}
|
|
37
|
+
const serverURL = readServerApiURL(runtimeConfig);
|
|
38
|
+
if (!serverURL || serverURL === baseURL) {
|
|
39
|
+
return { baseURL };
|
|
40
|
+
}
|
|
41
|
+
const transport = createRebasedTransport(baseURL, serverURL);
|
|
42
|
+
return {
|
|
43
|
+
baseURL,
|
|
44
|
+
httpClient: () => new Client({ baseURL, transport })
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
LOCALE_UNSET,
|
|
6
6
|
install
|
|
7
7
|
} from "@authup/client-web-kit";
|
|
8
|
-
import { API_URL_DEFAULT } from "@authup/core-http-kit";
|
|
9
8
|
import { getPathValue } from "pathtrace";
|
|
10
9
|
import { computed } from "vue";
|
|
11
10
|
import {
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
useRequestURL,
|
|
16
15
|
useRuntimeConfig
|
|
17
16
|
} from "#imports";
|
|
17
|
+
import { buildHTTPClientOptions } from "../helpers/http-client.js";
|
|
18
18
|
function buildPreferenceRef(name, unset, options) {
|
|
19
19
|
const cookie = useCookie(name, {
|
|
20
20
|
path: "/",
|
|
@@ -64,45 +64,18 @@ function buildCookieName(runtimeConfig) {
|
|
|
64
64
|
}
|
|
65
65
|
return (key) => `${options.cookiePrefix}${key}`;
|
|
66
66
|
}
|
|
67
|
-
function buildApiUrl(runtimeConfig) {
|
|
68
|
-
const options = runtimeConfig.public.authup;
|
|
69
|
-
let url;
|
|
70
|
-
if (import.meta.server) {
|
|
71
|
-
if (options.apiURLRuntimeKey) {
|
|
72
|
-
const pathValue = getPathValue(runtimeConfig, options.apiURLRuntimeKey);
|
|
73
|
-
if (typeof pathValue === "string") {
|
|
74
|
-
url = pathValue;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const serverOptions = runtimeConfig.authup;
|
|
78
|
-
if (serverOptions?.serverApiURL) {
|
|
79
|
-
url = serverOptions.serverApiURL;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (!url) {
|
|
83
|
-
if (options.apiURL) {
|
|
84
|
-
url = options.apiURL;
|
|
85
|
-
}
|
|
86
|
-
if (options.apiURLRuntimeKey) {
|
|
87
|
-
const pathValue = getPathValue(runtimeConfig.public, options.apiURLRuntimeKey);
|
|
88
|
-
if (typeof pathValue === "string") {
|
|
89
|
-
url = pathValue;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return url || API_URL_DEFAULT;
|
|
94
|
-
}
|
|
95
67
|
export default defineNuxtPlugin({
|
|
96
68
|
name: "authup:kit",
|
|
97
69
|
dependsOn: ["pinia"],
|
|
98
70
|
setup(ctx) {
|
|
99
71
|
const runtimeConfig = useRuntimeConfig();
|
|
100
|
-
const baseURL =
|
|
72
|
+
const { baseURL, httpClient } = buildHTTPClientOptions(runtimeConfig, import.meta.server);
|
|
101
73
|
const cookieOptions = buildCookieOptions(runtimeConfig);
|
|
102
74
|
const cookieName = buildCookieName(runtimeConfig);
|
|
103
75
|
install(ctx.vueApp, {
|
|
104
76
|
pinia: ctx.$pinia,
|
|
105
77
|
baseURL,
|
|
78
|
+
httpClient,
|
|
106
79
|
// A refresh during the server render rotates the token cookies
|
|
107
80
|
// too, and the kit cannot see the scheme without a window.
|
|
108
81
|
cookieSecure: useRequestURL().protocol === "https:",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authup/client-web-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.71",
|
|
5
5
|
"description": "Nuxt module that signs your app in with Authup and guards its routes by login state and permission.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -32,22 +32,22 @@
|
|
|
32
32
|
"node": "^22.13.0 || ^23.5.0 || >=24.0.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@authup/access": "^1.0.0-beta.
|
|
36
|
-
"@authup/client-web-kit": "^1.0.0-beta.
|
|
37
|
-
"@authup/core-http-kit": "^1.0.0-beta.
|
|
38
|
-
"@authup/kit": "^1.0.0-beta.
|
|
35
|
+
"@authup/access": "^1.0.0-beta.71",
|
|
36
|
+
"@authup/client-web-kit": "^1.0.0-beta.71",
|
|
37
|
+
"@authup/core-http-kit": "^1.0.0-beta.71",
|
|
38
|
+
"@authup/kit": "^1.0.0-beta.71",
|
|
39
39
|
"@nuxt/kit": "^4.6.1",
|
|
40
40
|
"pathtrace": "^2.2.0",
|
|
41
41
|
"smob": "^1.6.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@nuxt/module-builder": "^1.0.3",
|
|
45
|
-
"@nuxt/schema": "^4.6.
|
|
45
|
+
"@nuxt/schema": "^4.6.2",
|
|
46
46
|
"@pinia/nuxt": "^1.0.3",
|
|
47
47
|
"cross-env": "^10.1.0",
|
|
48
48
|
"fix-dts-default-cjs-exports": "^1.0.1",
|
|
49
49
|
"mkdist": "^2.3.0",
|
|
50
|
-
"nuxt": "^4.6.
|
|
50
|
+
"nuxt": "^4.6.2",
|
|
51
51
|
"pinia": "^4.1.0",
|
|
52
52
|
"rollup-plugin-dts": "^6.5.1",
|
|
53
53
|
"strip-literal": "^4.0.0",
|