@meistrari/auth-nuxt 0.1.0 → 1.0.0-beta.1
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 +272 -124
- package/dist/core.d.mts +1 -0
- package/dist/core.mjs +1 -0
- package/dist/module.d.mts +1 -3
- package/dist/module.json +3 -3
- package/dist/module.mjs +20 -26
- package/dist/runtime/composables/api-key.d.ts +13 -0
- package/dist/runtime/composables/api-key.js +29 -0
- package/dist/runtime/composables/organization.d.ts +28 -0
- package/dist/runtime/composables/organization.js +164 -0
- package/dist/runtime/composables/session.d.ts +18 -0
- package/dist/runtime/composables/session.js +88 -0
- package/dist/runtime/composables/state.d.ts +22 -0
- package/dist/runtime/composables/state.js +17 -0
- package/dist/runtime/plugin.d.ts +1 -14
- package/dist/runtime/plugin.js +69 -84
- package/dist/runtime/server/middleware/auth.js +11 -16
- package/dist/runtime/server/tsconfig.json +4 -1
- package/dist/runtime/server/types/h3.d.ts +5 -5
- package/dist/runtime/shared.d.ts +1 -0
- package/dist/runtime/shared.js +19 -0
- package/package.json +51 -48
- package/dist/runtime/composable.d.ts +0 -5
- package/dist/runtime/composable.js +0 -29
- package/dist/runtime/server/api/sign-out.d.ts +0 -2
- package/dist/runtime/server/api/sign-out.js +0 -16
- package/dist/runtime/server/middleware/set-cookies.d.ts +0 -2
- package/dist/runtime/server/middleware/set-cookies.js +0 -42
package/package.json
CHANGED
|
@@ -1,51 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
"name": "@meistrari/auth-nuxt",
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/types.d.mts",
|
|
8
|
+
"import": "./dist/module.mjs"
|
|
9
|
+
},
|
|
10
|
+
"./server/middleware/auth": {
|
|
11
|
+
"types": "./dist/runtime/server/middleware/auth.d.ts",
|
|
12
|
+
"import": "./dist/runtime/server/middleware/auth.js"
|
|
13
|
+
},
|
|
14
|
+
"./core": {
|
|
15
|
+
"types": "./dist/core.d.mts",
|
|
16
|
+
"import": "./dist/core.mjs"
|
|
17
|
+
}
|
|
9
18
|
},
|
|
10
|
-
"./
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
19
|
+
"main": "./dist/module.mjs",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {
|
|
22
|
+
".": [
|
|
23
|
+
"./dist/types.d.mts"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@meistrari/auth-core": "1.3.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"nuxt": "^3.0.0 || ^4.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@nuxt/devtools": "2.6.3",
|
|
41
|
+
"@nuxt/eslint-config": "1.9.0",
|
|
42
|
+
"@nuxt/kit": "4.0.3",
|
|
43
|
+
"@nuxt/module-builder": "1.0.2",
|
|
44
|
+
"@nuxt/schema": "4.0.3",
|
|
45
|
+
"@nuxt/test-utils": "3.19.2",
|
|
46
|
+
"@types/node": "latest",
|
|
47
|
+
"changelogen": "0.6.2",
|
|
48
|
+
"nuxt": "4.0.3",
|
|
49
|
+
"typescript": "5.9.2",
|
|
50
|
+
"unbuild": "3.6.1",
|
|
51
|
+
"vitest": "3.2.4",
|
|
52
|
+
"vue-tsc": "3.0.6"
|
|
21
53
|
}
|
|
22
|
-
|
|
23
|
-
"files": [
|
|
24
|
-
"dist"
|
|
25
|
-
],
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build"
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@meistrari/auth-core": "0.1.1"
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"nuxt": "^3.0.0 || ^4.0.0"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@nuxt/devtools": "2.6.3",
|
|
37
|
-
"@nuxt/eslint-config": "1.9.0",
|
|
38
|
-
"@nuxt/kit": "4.0.3",
|
|
39
|
-
"@nuxt/module-builder": "1.0.2",
|
|
40
|
-
"@nuxt/schema": "4.0.3",
|
|
41
|
-
"@nuxt/test-utils": "3.19.2",
|
|
42
|
-
"@types/node": "latest",
|
|
43
|
-
"changelogen": "0.6.2",
|
|
44
|
-
"eslint": "9.34.0",
|
|
45
|
-
"nuxt": "4.0.3",
|
|
46
|
-
"typescript": "5.9.2",
|
|
47
|
-
"unbuild": "3.6.1",
|
|
48
|
-
"vitest": "3.2.4",
|
|
49
|
-
"vue-tsc": "3.0.6"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
54
|
+
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useCookie, useState, useRuntimeConfig, useNuxtApp } from "#app";
|
|
2
|
-
export function useMeistrariAuth() {
|
|
3
|
-
const user = useState("user", () => null);
|
|
4
|
-
const session = useState("session", () => null);
|
|
5
|
-
const { useJwt, jwtCookieName, isDevelopment } = useRuntimeConfig().public.auth;
|
|
6
|
-
const { $auth } = useNuxtApp();
|
|
7
|
-
async function signOut(callback) {
|
|
8
|
-
await $auth.client.signOut({
|
|
9
|
-
fetchOptions: {
|
|
10
|
-
onSuccess: async () => {
|
|
11
|
-
if (useJwt) {
|
|
12
|
-
useCookie(jwtCookieName).value = null;
|
|
13
|
-
}
|
|
14
|
-
if (isDevelopment) {
|
|
15
|
-
await $fetch("/api/meistrari-auth/sign-out");
|
|
16
|
-
}
|
|
17
|
-
user.value = null;
|
|
18
|
-
session.value = null;
|
|
19
|
-
callback?.();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
user,
|
|
26
|
-
session,
|
|
27
|
-
signOut
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, deleteCookie, sendNoContent } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
deleteCookie(event, "__Secure-__session", {
|
|
4
|
-
httpOnly: true,
|
|
5
|
-
secure: true,
|
|
6
|
-
sameSite: "lax",
|
|
7
|
-
path: "/"
|
|
8
|
-
});
|
|
9
|
-
deleteCookie(event, "__Secure-__session_data", {
|
|
10
|
-
httpOnly: true,
|
|
11
|
-
secure: true,
|
|
12
|
-
sameSite: "lax",
|
|
13
|
-
path: "/"
|
|
14
|
-
});
|
|
15
|
-
return sendNoContent(event);
|
|
16
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery, setCookie, sendRedirect, getRequestURL } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const query = getQuery(event);
|
|
4
|
-
const hasSessionParam = query.session && typeof query.session === "string";
|
|
5
|
-
const hasSessionDataParam = query.session_data && typeof query.session_data === "string";
|
|
6
|
-
if (hasSessionParam || hasSessionDataParam) {
|
|
7
|
-
if (hasSessionParam) {
|
|
8
|
-
setCookie(event, "__Secure-__session", query.session, {
|
|
9
|
-
httpOnly: true,
|
|
10
|
-
secure: true,
|
|
11
|
-
sameSite: "lax",
|
|
12
|
-
path: "/",
|
|
13
|
-
maxAge: 60 * 60 * 24 * 7
|
|
14
|
-
// 1 week in seconds
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
if (hasSessionDataParam) {
|
|
18
|
-
setCookie(event, "__Secure-__session_data", query.session_data, {
|
|
19
|
-
httpOnly: true,
|
|
20
|
-
secure: true,
|
|
21
|
-
sameSite: "lax",
|
|
22
|
-
path: "/",
|
|
23
|
-
maxAge: 60 * 60 * 24 * 7
|
|
24
|
-
// 1 week in seconds
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const url = getRequestURL(event);
|
|
28
|
-
const newQuery = new URLSearchParams();
|
|
29
|
-
for (const [key, value] of Object.entries(query)) {
|
|
30
|
-
if (key !== "session" && key !== "session_data" && value !== void 0 && value !== null) {
|
|
31
|
-
if (Array.isArray(value)) {
|
|
32
|
-
value.forEach((v) => newQuery.append(key, String(v)));
|
|
33
|
-
} else {
|
|
34
|
-
newQuery.append(key, String(value));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const queryString = newQuery.toString();
|
|
39
|
-
const redirectUrl = `${url.pathname}${queryString ? `?${queryString}` : ""}`;
|
|
40
|
-
return sendRedirect(event, redirectUrl, 302);
|
|
41
|
-
}
|
|
42
|
-
});
|