@authup/client-web-nuxt 1.0.0-beta.20 → 1.0.0-beta.22
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 +1 -18
- package/dist/module.d.ts +1 -18
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -5
- package/dist/runtime/plugins/kit.js +95 -0
- package/dist/runtime/plugins/root.d.ts +2 -0
- package/dist/runtime/plugins/root.js +7 -0
- package/dist/runtime/types.d.ts +0 -8
- package/package.json +6 -4
- package/dist/runtime/plugins/00.pinia.d.ts +0 -6
- package/dist/runtime/plugins/00.pinia.js +0 -24
- package/dist/runtime/plugins/01.kit.js +0 -90
- /package/dist/runtime/plugins/{01.kit.d.ts → kit.d.ts} +0 -0
package/dist/module.d.mts
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
|
|
3
|
-
type AuthupRuntimeOptions = {
|
|
4
|
-
apiURL?: string;
|
|
5
|
-
apiURLRuntimeKey?: string;
|
|
6
|
-
/**
|
|
7
|
-
* Separate apiURL for server side rendering.
|
|
8
|
-
*/
|
|
9
|
-
apiURLServer?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Separate extraction of apiURL for server side rendering.
|
|
12
|
-
*/
|
|
13
|
-
apiURLServerRuntimeKey?: string;
|
|
14
|
-
cookieDomain?: string;
|
|
15
|
-
cookieDomainRuntimeKey?: string;
|
|
16
|
-
homeRoute?: string;
|
|
17
|
-
loginRoute?: string;
|
|
18
|
-
logoutRoute?: string;
|
|
19
|
-
};
|
|
2
|
+
import { AuthupRuntimeOptions } from '../dist/runtime/types.js';
|
|
20
3
|
|
|
21
4
|
declare const _default: _nuxt_schema.NuxtModule<AuthupRuntimeOptions, AuthupRuntimeOptions, false>;
|
|
22
5
|
|
package/dist/module.d.ts
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
|
|
3
|
-
type AuthupRuntimeOptions = {
|
|
4
|
-
apiURL?: string;
|
|
5
|
-
apiURLRuntimeKey?: string;
|
|
6
|
-
/**
|
|
7
|
-
* Separate apiURL for server side rendering.
|
|
8
|
-
*/
|
|
9
|
-
apiURLServer?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Separate extraction of apiURL for server side rendering.
|
|
12
|
-
*/
|
|
13
|
-
apiURLServerRuntimeKey?: string;
|
|
14
|
-
cookieDomain?: string;
|
|
15
|
-
cookieDomainRuntimeKey?: string;
|
|
16
|
-
homeRoute?: string;
|
|
17
|
-
loginRoute?: string;
|
|
18
|
-
logoutRoute?: string;
|
|
19
|
-
};
|
|
2
|
+
import { AuthupRuntimeOptions } from '../dist/runtime/types.js';
|
|
20
3
|
|
|
21
4
|
declare const _default: _nuxt_schema.NuxtModule<AuthupRuntimeOptions, AuthupRuntimeOptions, false>;
|
|
22
5
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, addPlugin, addRouteMiddleware } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, installModule, addPlugin, addRouteMiddleware } from '@nuxt/kit';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { merge } from 'smob';
|
|
@@ -10,13 +10,12 @@ const module = defineNuxtModule({
|
|
|
10
10
|
},
|
|
11
11
|
defaults: {},
|
|
12
12
|
async setup(options, nuxt) {
|
|
13
|
+
await installModule("@pinia/nuxt");
|
|
13
14
|
const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
|
|
14
15
|
nuxt.options.build.transpile.push(runtimeDir);
|
|
15
16
|
const runtimeOptions = {
|
|
16
17
|
apiURL: options.apiURL,
|
|
17
18
|
apiURLRuntimeKey: options.apiURLRuntimeKey,
|
|
18
|
-
apiURLServer: options.apiURLServer,
|
|
19
|
-
apiURLServerRuntimeKey: options.apiURLServerRuntimeKey,
|
|
20
19
|
cookieDomain: options.cookieDomain,
|
|
21
20
|
cookieDomainRuntimeKey: options.cookieDomainRuntimeKey,
|
|
22
21
|
homeRoute: options.homeRoute,
|
|
@@ -32,8 +31,8 @@ const module = defineNuxtModule({
|
|
|
32
31
|
} else {
|
|
33
32
|
nuxt.options.runtimeConfig.public.authup = runtimeOptions;
|
|
34
33
|
}
|
|
35
|
-
addPlugin(path.resolve(runtimeDir, "plugins/
|
|
36
|
-
addPlugin(path.resolve(runtimeDir, "plugins/
|
|
34
|
+
addPlugin(path.resolve(runtimeDir, "plugins/kit"));
|
|
35
|
+
addPlugin(path.resolve(runtimeDir, "plugins/root"));
|
|
37
36
|
addRouteMiddleware({
|
|
38
37
|
name: "loggedIn",
|
|
39
38
|
path: path.resolve(runtimeDir, "middleware/00.session"),
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { install } from "@authup/client-web-kit";
|
|
2
|
+
import { getPathValue } from "pathtrace";
|
|
3
|
+
import {
|
|
4
|
+
defineNuxtPlugin,
|
|
5
|
+
tryUseNuxtApp,
|
|
6
|
+
useCookie,
|
|
7
|
+
useRuntimeConfig
|
|
8
|
+
} from "#imports";
|
|
9
|
+
function buildCookieOptions(runtimeConfig) {
|
|
10
|
+
const options = runtimeConfig.public.authup;
|
|
11
|
+
let domain;
|
|
12
|
+
if (options.cookieDomain) {
|
|
13
|
+
domain = options.cookieDomain;
|
|
14
|
+
}
|
|
15
|
+
if (options.cookieDomainRuntimeKey) {
|
|
16
|
+
const pathValue = getPathValue(runtimeConfig.public, options.cookieDomainRuntimeKey);
|
|
17
|
+
if (typeof pathValue === "string") {
|
|
18
|
+
domain = pathValue;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (domain === "127.0.0.1") {
|
|
22
|
+
domain = "localhost";
|
|
23
|
+
}
|
|
24
|
+
const cookieOptions = {};
|
|
25
|
+
if (domain) {
|
|
26
|
+
cookieOptions.domain = domain;
|
|
27
|
+
}
|
|
28
|
+
return cookieOptions;
|
|
29
|
+
}
|
|
30
|
+
function buildApiUrl(runtimeConfig) {
|
|
31
|
+
const options = runtimeConfig.public.authup;
|
|
32
|
+
let url;
|
|
33
|
+
if (import.meta.server) {
|
|
34
|
+
if (options.apiURLRuntimeKey) {
|
|
35
|
+
const pathValue = getPathValue(runtimeConfig, options.apiURLRuntimeKey);
|
|
36
|
+
if (typeof pathValue === "string") {
|
|
37
|
+
url = pathValue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!url) {
|
|
42
|
+
if (options.apiURL) {
|
|
43
|
+
url = options.apiURL;
|
|
44
|
+
}
|
|
45
|
+
if (options.apiURLRuntimeKey) {
|
|
46
|
+
const pathValue = getPathValue(runtimeConfig.public, options.apiURLRuntimeKey);
|
|
47
|
+
if (typeof pathValue === "string") {
|
|
48
|
+
url = pathValue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return url || "http://localhost:3010";
|
|
53
|
+
}
|
|
54
|
+
export default defineNuxtPlugin({
|
|
55
|
+
name: "authup:kit",
|
|
56
|
+
dependsOn: ["pinia"],
|
|
57
|
+
setup(ctx) {
|
|
58
|
+
const runtimeConfig = useRuntimeConfig();
|
|
59
|
+
const baseURL = buildApiUrl(runtimeConfig);
|
|
60
|
+
const cookieOptions = buildCookieOptions(runtimeConfig);
|
|
61
|
+
install(ctx.vueApp, {
|
|
62
|
+
pinia: ctx.$pinia,
|
|
63
|
+
baseURL,
|
|
64
|
+
cookieSet: (key, value, options) => {
|
|
65
|
+
const app = tryUseNuxtApp();
|
|
66
|
+
if (app) {
|
|
67
|
+
const cookie = useCookie(key, {
|
|
68
|
+
...cookieOptions,
|
|
69
|
+
...options || {}
|
|
70
|
+
});
|
|
71
|
+
cookie.value = value;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
cookieUnset: (key, options) => {
|
|
75
|
+
const app = tryUseNuxtApp();
|
|
76
|
+
if (app) {
|
|
77
|
+
const cookie = useCookie(key, {
|
|
78
|
+
...cookieOptions,
|
|
79
|
+
...options || {}
|
|
80
|
+
});
|
|
81
|
+
cookie.value = null;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
cookieGet: (key) => {
|
|
85
|
+
const app = tryUseNuxtApp();
|
|
86
|
+
if (app) {
|
|
87
|
+
const cookie = useCookie(key);
|
|
88
|
+
return cookie.value;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
},
|
|
92
|
+
isServer: import.meta.server
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
export type AuthupRuntimeOptions = {
|
|
2
2
|
apiURL?: string;
|
|
3
3
|
apiURLRuntimeKey?: string;
|
|
4
|
-
/**
|
|
5
|
-
* Separate apiURL for server side rendering.
|
|
6
|
-
*/
|
|
7
|
-
apiURLServer?: string;
|
|
8
|
-
/**
|
|
9
|
-
* Separate extraction of apiURL for server side rendering.
|
|
10
|
-
*/
|
|
11
|
-
apiURLServerRuntimeKey?: string;
|
|
12
4
|
cookieDomain?: string;
|
|
13
5
|
cookieDomainRuntimeKey?: string;
|
|
14
6
|
homeRoute?: string;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.22",
|
|
5
5
|
"description": "Nuxt module for the authup ecosystem",
|
|
6
|
+
"license": "Apache-2.0",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "git+https://github.com/authup/authup.git",
|
|
9
10
|
"directory": "packages/client-web-nuxt"
|
|
10
11
|
},
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/types.d.ts",
|
|
@@ -29,18 +29,20 @@
|
|
|
29
29
|
"lint": "eslint ."
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@authup/kit": "^1.0.0-beta.
|
|
33
|
-
"@authup/client-web-kit": "^1.0.0-beta.
|
|
32
|
+
"@authup/kit": "^1.0.0-beta.22",
|
|
33
|
+
"@authup/client-web-kit": "^1.0.0-beta.22",
|
|
34
34
|
"@nuxt/kit": "^3.13.2",
|
|
35
35
|
"pathtrace": "^1.1.0",
|
|
36
36
|
"smob": "^1.5.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@nuxt/module-builder": "^0.8.4",
|
|
40
|
+
"@pinia/nuxt": "^0.5.5",
|
|
40
41
|
"nuxt": "^3.13.2",
|
|
41
42
|
"pinia": "^2.2.4"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
45
|
+
"@pinia/nuxt": "*",
|
|
44
46
|
"pinia": "^2.2.4"
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createPinia, setActivePinia } from "pinia";
|
|
2
|
-
import { defineNuxtPlugin } from "#imports";
|
|
3
|
-
export default defineNuxtPlugin({
|
|
4
|
-
name: "authupPinia",
|
|
5
|
-
enforce: "pre",
|
|
6
|
-
async setup(nuxt) {
|
|
7
|
-
if (nuxt.$pinia) {
|
|
8
|
-
return {};
|
|
9
|
-
}
|
|
10
|
-
const pinia = createPinia();
|
|
11
|
-
nuxt.vueApp.use(pinia);
|
|
12
|
-
setActivePinia(pinia);
|
|
13
|
-
if (import.meta.server) {
|
|
14
|
-
nuxt.payload.pinia = pinia.state.value;
|
|
15
|
-
} else if (nuxt.payload && nuxt.payload.pinia) {
|
|
16
|
-
pinia.state.value = nuxt.payload.pinia;
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
provide: {
|
|
20
|
-
pinia
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
});
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { install } from "@authup/client-web-kit";
|
|
2
|
-
import { getPathValue } from "pathtrace";
|
|
3
|
-
import {
|
|
4
|
-
defineNuxtPlugin,
|
|
5
|
-
tryUseNuxtApp,
|
|
6
|
-
useCookie,
|
|
7
|
-
useRuntimeConfig
|
|
8
|
-
} from "#imports";
|
|
9
|
-
export default defineNuxtPlugin({
|
|
10
|
-
name: "authupKit",
|
|
11
|
-
enforce: "pre",
|
|
12
|
-
dependsOn: ["authupPinia"],
|
|
13
|
-
setup(ctx) {
|
|
14
|
-
const runtimeConfig = useRuntimeConfig();
|
|
15
|
-
let apiURL;
|
|
16
|
-
let apiURLServer;
|
|
17
|
-
let cookieDomain;
|
|
18
|
-
const runtimeOptions = runtimeConfig.public.authup;
|
|
19
|
-
if (import.meta.server && (runtimeOptions.apiURLServer || runtimeOptions.apiURLServerRuntimeKey)) {
|
|
20
|
-
if (runtimeOptions.apiURLServer) {
|
|
21
|
-
apiURLServer = runtimeOptions.apiURLServer;
|
|
22
|
-
}
|
|
23
|
-
if (runtimeOptions.apiURLServerRuntimeKey) {
|
|
24
|
-
let pathValue = getPathValue(runtimeConfig, runtimeOptions.apiURLServerRuntimeKey);
|
|
25
|
-
if (typeof pathValue === "string") {
|
|
26
|
-
apiURLServer = pathValue;
|
|
27
|
-
}
|
|
28
|
-
pathValue = getPathValue(runtimeConfig.public, runtimeOptions.apiURLServerRuntimeKey);
|
|
29
|
-
if (typeof pathValue === "string") {
|
|
30
|
-
apiURLServer = pathValue;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (runtimeOptions.apiURL) {
|
|
35
|
-
apiURL = runtimeOptions.apiURL;
|
|
36
|
-
}
|
|
37
|
-
if (runtimeOptions.apiURLRuntimeKey) {
|
|
38
|
-
const pathValue = getPathValue(runtimeConfig.public, runtimeOptions.apiURLRuntimeKey);
|
|
39
|
-
if (typeof pathValue === "string") {
|
|
40
|
-
apiURL = pathValue;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (runtimeOptions.cookieDomain) {
|
|
44
|
-
cookieDomain = runtimeOptions.cookieDomain;
|
|
45
|
-
}
|
|
46
|
-
if (runtimeOptions.cookieDomainRuntimeKey) {
|
|
47
|
-
const pathValue = getPathValue(runtimeConfig.public, runtimeOptions.cookieDomainRuntimeKey);
|
|
48
|
-
if (typeof pathValue === "string") {
|
|
49
|
-
cookieDomain = pathValue;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (!cookieDomain) {
|
|
53
|
-
const { hostname } = new URL(apiURL || "http://localhost:3000");
|
|
54
|
-
cookieDomain = hostname;
|
|
55
|
-
}
|
|
56
|
-
if (cookieDomain === "127.0.0.1") {
|
|
57
|
-
cookieDomain = "localhost";
|
|
58
|
-
}
|
|
59
|
-
const cookieOptions = {
|
|
60
|
-
domain: cookieDomain || "localhost"
|
|
61
|
-
};
|
|
62
|
-
install(ctx.vueApp, {
|
|
63
|
-
pinia: ctx.$pinia,
|
|
64
|
-
baseURL: apiURLServer || apiURL || "http://localhost:3000",
|
|
65
|
-
cookieSet: (key, value) => {
|
|
66
|
-
const app = tryUseNuxtApp();
|
|
67
|
-
if (app) {
|
|
68
|
-
const cookie = useCookie(key, cookieOptions);
|
|
69
|
-
cookie.value = value;
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
cookieUnset: (key) => {
|
|
73
|
-
const app = tryUseNuxtApp();
|
|
74
|
-
if (app) {
|
|
75
|
-
const cookie = useCookie(key, cookieOptions);
|
|
76
|
-
cookie.value = null;
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
cookieGet: (key) => {
|
|
80
|
-
const app = tryUseNuxtApp();
|
|
81
|
-
if (app) {
|
|
82
|
-
const cookie = useCookie(key, cookieOptions);
|
|
83
|
-
return cookie.value;
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
86
|
-
},
|
|
87
|
-
isServer: import.meta.server
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
});
|
|
File without changes
|