@meistrari/auth-nuxt 3.8.0 → 3.8.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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/auth-nuxt",
3
3
  "configKey": "telaAuth",
4
- "version": "3.8.0",
4
+ "version": "3.0.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -2,11 +2,11 @@ import { useCookie, useRequestURL, useRuntimeConfig } from "#app";
2
2
  import { createNuxtAuthClient } from "../shared.js";
3
3
  export function useTelaApiKey() {
4
4
  const { application, jwtCookieName, apiUrl } = useRuntimeConfig().public.telaAuth;
5
- const tokenCookie = useCookie(application?.enabled ? "tela-access-token" : jwtCookieName);
5
+ const tokenCookie = useCookie(jwtCookieName);
6
6
  const requestUrl = useRequestURL();
7
7
  const authClient = createNuxtAuthClient(
8
8
  application?.enabled ? requestUrl.origin : apiUrl,
9
- () => tokenCookie.value ?? null
9
+ () => application?.enabled ? null : tokenCookie.value ?? null
10
10
  );
11
11
  async function createApiKey(payload) {
12
12
  return await authClient.apiKey.createApiKey(payload);
@@ -16,26 +16,9 @@ const ALLOWED_RESPONSE_HEADERS = /* @__PURE__ */ new Set([
16
16
  "cache-control",
17
17
  "content-type"
18
18
  ]);
19
- const ALLOWED_API_KEY_ROUTES = /* @__PURE__ */ new Map([
20
- ["/api/auth/api-key/create", /* @__PURE__ */ new Set(["POST"])],
21
- ["/api/auth/api-key/delete", /* @__PURE__ */ new Set(["POST"])],
22
- ["/api/auth/api-key/get", /* @__PURE__ */ new Set(["GET"])],
23
- ["/api/auth/api-key/list", /* @__PURE__ */ new Set(["GET"])],
24
- ["/api/auth/api-key/update", /* @__PURE__ */ new Set(["POST"])]
25
- ]);
26
- function getBearerToken(authorization) {
27
- const value = Array.isArray(authorization) ? authorization[0] : authorization;
28
- if (!value?.toLowerCase().startsWith("bearer ")) {
29
- return void 0;
30
- }
31
- return value.slice("bearer ".length).trimStart() || void 0;
32
- }
33
19
  export default defineEventHandler(async (event) => {
34
20
  const authConfig = useRuntimeConfig(event).public.telaAuth;
35
- const requestUrl = getRequestURL(event);
36
- const requestHeaders = getHeaders(event);
37
- const accessToken = getCookie(event, "tela-access-token") ?? getBearerToken(requestHeaders.authorization);
38
- const allowedMethods = ALLOWED_API_KEY_ROUTES.get(requestUrl.pathname);
21
+ const accessToken = getCookie(event, "tela-access-token");
39
22
  if (!authConfig.application?.enabled) {
40
23
  throw createError({
41
24
  statusCode: 404,
@@ -49,28 +32,10 @@ export default defineEventHandler(async (event) => {
49
32
  message: "No access token found"
50
33
  });
51
34
  }
52
- if (!allowedMethods) {
53
- throw createError({
54
- statusCode: 404,
55
- statusMessage: "Not Found"
56
- });
57
- }
58
- if (!allowedMethods.has(event.method)) {
59
- throw createError({
60
- statusCode: 405,
61
- statusMessage: "Method Not Allowed"
62
- });
63
- }
64
- const origin = Array.isArray(requestHeaders.origin) ? requestHeaders.origin[0] : requestHeaders.origin;
65
- if (event.method !== "GET" && origin && origin !== requestUrl.origin) {
66
- throw createError({
67
- statusCode: 403,
68
- statusMessage: "Forbidden"
69
- });
70
- }
35
+ const requestUrl = getRequestURL(event);
71
36
  const targetUrl = new URL(requestUrl.pathname + requestUrl.search, authConfig.apiUrl);
72
37
  const headers = new Headers();
73
- for (const [name, value] of Object.entries(requestHeaders)) {
38
+ for (const [name, value] of Object.entries(getHeaders(event))) {
74
39
  if (value && ALLOWED_REQUEST_HEADERS.has(name.toLowerCase())) {
75
40
  headers.set(name, Array.isArray(value) ? value.join(", ") : value);
76
41
  }
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
1
  {
2
- "name": "@meistrari/auth-nuxt",
3
- "version": "3.8.0",
4
- "type": "module",
5
- "exports": {
6
- ".": {
7
- "types": "./dist/types.d.mts",
8
- "import": "./dist/module.mjs"
2
+ "name": "@meistrari/auth-nuxt",
3
+ "version": "3.8.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
+ "./server/middleware/application-auth": {
15
+ "types": "./dist/runtime/server/middleware/application-auth.d.ts",
16
+ "import": "./dist/runtime/server/middleware/application-auth.js"
17
+ },
18
+ "./core": {
19
+ "types": "./dist/core.d.mts",
20
+ "import": "./dist/core.mjs"
21
+ }
9
22
  },
10
- "./server/middleware/auth": {
11
- "types": "./dist/runtime/server/middleware/auth.d.ts",
12
- "import": "./dist/runtime/server/middleware/auth.js"
23
+ "main": "./dist/module.mjs",
24
+ "typesVersions": {
25
+ "*": {
26
+ ".": [
27
+ "./dist/types.d.mts"
28
+ ]
29
+ }
13
30
  },
14
- "./server/middleware/application-auth": {
15
- "types": "./dist/runtime/server/middleware/application-auth.d.ts",
16
- "import": "./dist/runtime/server/middleware/application-auth.js"
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "scripts": {
35
+ "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build",
36
+ "docs": "nuxt-module-build prepare && typedoc"
17
37
  },
18
- "./core": {
19
- "types": "./dist/core.d.mts",
20
- "import": "./dist/core.mjs"
21
- }
22
- },
23
- "main": "./dist/module.mjs",
24
- "typesVersions": {
25
- "*": {
26
- ".": [
27
- "./dist/types.d.mts"
28
- ]
38
+ "dependencies": {
39
+ "@meistrari/auth-core": "1.19.0",
40
+ "jose": "6.1.3"
41
+ },
42
+ "peerDependencies": {
43
+ "nuxt": "^3.0.0 || ^4.0.0",
44
+ "vue": "^3.0.0"
45
+ },
46
+ "devDependencies": {
47
+ "@nuxt/devtools": "2.6.3",
48
+ "@nuxt/eslint-config": "1.9.0",
49
+ "@nuxt/kit": "4.0.3",
50
+ "@nuxt/module-builder": "1.0.2",
51
+ "@nuxt/schema": "4.0.3",
52
+ "@nuxt/test-utils": "3.19.2",
53
+ "@types/node": "latest",
54
+ "changelogen": "0.6.2",
55
+ "nuxt": "4.0.3",
56
+ "typescript": "5.9.2",
57
+ "unbuild": "3.6.1",
58
+ "typedoc": "0.28.18",
59
+ "typedoc-plugin-markdown": "4.11.0",
60
+ "vitest": "3.2.4",
61
+ "vue-tsc": "3.0.6"
29
62
  }
30
- },
31
- "files": [
32
- "dist"
33
- ],
34
- "scripts": {
35
- "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build",
36
- "docs": "nuxt-module-build prepare && typedoc"
37
- },
38
- "dependencies": {
39
- "@meistrari/auth-core": "workspace:*",
40
- "jose": "6.1.3"
41
- },
42
- "peerDependencies": {
43
- "nuxt": "^3.0.0 || ^4.0.0",
44
- "vue": "^3.0.0"
45
- },
46
- "devDependencies": {
47
- "@nuxt/devtools": "2.6.3",
48
- "@nuxt/eslint-config": "1.9.0",
49
- "@nuxt/kit": "4.0.3",
50
- "@nuxt/module-builder": "1.0.2",
51
- "@nuxt/schema": "4.0.3",
52
- "@nuxt/test-utils": "3.19.2",
53
- "@types/node": "latest",
54
- "changelogen": "0.6.2",
55
- "nuxt": "4.0.3",
56
- "typescript": "5.9.2",
57
- "unbuild": "3.6.1",
58
- "typedoc": "0.28.18",
59
- "typedoc-plugin-markdown": "4.11.0",
60
- "vitest": "3.2.4",
61
- "vue-tsc": "3.0.6"
62
- }
63
63
  }