@meistrari/auth-nuxt 2.1.1 → 2.1.2

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": "2.1.1",
4
+ "version": "2.1.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -21,7 +21,15 @@ onMounted(async () => {
21
21
  </script>
22
22
 
23
23
  <template>
24
- <div class="flex items-center justify-center min-h-screen">
25
- <h1>Loading...</h1>
24
+ <div class="callback-screen">
25
+ <div class="callback-square">
26
+ <div class="callback-border-mask">
27
+ <div class="callback-border-traveler" />
28
+ </div>
29
+ </div>
26
30
  </div>
27
31
  </template>
32
+
33
+ <style scoped>
34
+ .callback-screen{align-items:center;background:#fff;display:flex;height:100dvh;inset:0;justify-content:center;position:fixed;width:100dvw;z-index:9999}.callback-square{background:#fff;border:4px solid #9ca1a9;height:2rem;position:relative;width:2rem}.callback-border-mask{border:4px solid transparent;inset:-4px;mask-clip:padding-box,border-box;-webkit-mask-clip:padding-box,border-box;-webkit-mask-composite:source-in,xor;mask-composite:intersect;-webkit-mask-composite:source-in;mask-image:linear-gradient(transparent,transparent),linear-gradient(#000,#000);-webkit-mask-image:linear-gradient(transparent,transparent),linear-gradient(#000,#000);position:absolute}.callback-border-traveler{animation:border-travel .8s ease-in-out infinite;aspect-ratio:1;background:#000;height:1rem;offset-path:rect(0 auto auto 0);position:absolute;width:40px}@keyframes border-travel{0%{offset-distance:0}to{offset-distance:100%}}
35
+ </style>
@@ -3,6 +3,7 @@ import { isTokenExpired, RefreshTokenExpiredError } from "@meistrari/auth-core";
3
3
  import { watch } from "vue";
4
4
  import { useApplicationSessionState } from "../composables/state.js";
5
5
  import { createNuxtAuthClient } from "../shared.js";
6
+ import { useTelaApplicationAuth } from "../composables/application-auth.js";
6
7
  const SEVEN_DAYS = 60 * 60 * 24 * 7;
7
8
  const FIFTEEN_MINUTES = 60 * 15;
8
9
  const TWO_MINUTES = 2 * 60 * 1e3;
@@ -10,9 +11,11 @@ function parseTokenExpiry(token) {
10
11
  try {
11
12
  const tokenParts = token.split(".");
12
13
  const payloadPart = tokenParts[1];
13
- if (!payloadPart) return null;
14
+ if (!payloadPart)
15
+ return null;
14
16
  const payload = JSON.parse(atob(payloadPart));
15
- if (!payload.exp) return null;
17
+ if (!payload.exp)
18
+ return null;
16
19
  return payload.exp * 1e3;
17
20
  } catch {
18
21
  return null;
@@ -37,6 +40,7 @@ export default defineNuxtPlugin({
37
40
  async setup() {
38
41
  const appConfig = useRuntimeConfig().public.telaAuth;
39
42
  const state = useApplicationSessionState();
43
+ const { login, logout: sdkLogout } = useTelaApplicationAuth();
40
44
  const accessTokenCookie = useCookie("tela-access-token", {
41
45
  secure: true,
42
46
  sameSite: "lax",
@@ -64,6 +68,11 @@ export default defineNuxtPlugin({
64
68
  refreshTokenCookie.value = refreshToken2;
65
69
  state.user.value = user;
66
70
  state.activeOrganization.value = mapOrganization(organization);
71
+ } catch {
72
+ await sdkLogout();
73
+ if (import.meta.client) {
74
+ await login();
75
+ }
67
76
  } finally {
68
77
  isRefreshing = false;
69
78
  }
@@ -99,9 +108,9 @@ export default defineNuxtPlugin({
99
108
  state.user.value = data.user;
100
109
  state.activeOrganization.value = mapOrganization(data.organization);
101
110
  } catch (error) {
102
- console.error(`[Tela Auth SDK] Failed to get user and organization:`, error.message);
111
+ console.error("[Tela Auth SDK] Failed to get user and organization:", error.message);
103
112
  if (!refreshTokenCookie.value) {
104
- console.error(`[Tela Auth SDK] Missing refresh token, logging out...`);
113
+ console.error("[Tela Auth SDK] Missing refresh token, logging out...");
105
114
  logout();
106
115
  return;
107
116
  }
@@ -12,7 +12,7 @@ export function requireAuth(handler, options) {
12
12
  message: "User is not authorized to access this resource"
13
13
  });
14
14
  }
15
- return handler(event);
15
+ return await handler(event);
16
16
  }
17
17
  const token = getCookie(event, "tela-access-token");
18
18
  const authConfig = useRuntimeConfig(event).public.telaAuth;
package/package.json CHANGED
@@ -1,56 +1,56 @@
1
1
  {
2
- "name": "@meistrari/auth-nuxt",
3
- "version": "2.1.1",
4
- "type": "module",
5
- "exports": {
6
- ".": {
7
- "types": "./dist/types.d.mts",
8
- "import": "./dist/module.mjs"
2
+ "name": "@meistrari/auth-nuxt",
3
+ "version": "2.1.2",
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
- "./server/middleware/auth": {
11
- "types": "./dist/runtime/server/middleware/auth.d.ts",
12
- "import": "./dist/runtime/server/middleware/auth.js"
19
+ "main": "./dist/module.mjs",
20
+ "typesVersions": {
21
+ "*": {
22
+ ".": [
23
+ "./dist/types.d.mts"
24
+ ]
25
+ }
13
26
  },
14
- "./core": {
15
- "types": "./dist/core.d.mts",
16
- "import": "./dist/core.mjs"
17
- }
18
- },
19
- "main": "./dist/module.mjs",
20
- "typesVersions": {
21
- "*": {
22
- ".": [
23
- "./dist/types.d.mts"
24
- ]
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.4.0",
35
+ "jose": "6.1.3"
36
+ },
37
+ "peerDependencies": {
38
+ "nuxt": "^3.0.0 || ^4.0.0",
39
+ "vue": "^3.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "@nuxt/devtools": "2.6.3",
43
+ "@nuxt/eslint-config": "1.9.0",
44
+ "@nuxt/kit": "4.0.3",
45
+ "@nuxt/module-builder": "1.0.2",
46
+ "@nuxt/schema": "4.0.3",
47
+ "@nuxt/test-utils": "3.19.2",
48
+ "@types/node": "latest",
49
+ "changelogen": "0.6.2",
50
+ "nuxt": "4.0.3",
51
+ "typescript": "5.9.2",
52
+ "unbuild": "3.6.1",
53
+ "vitest": "3.2.4",
54
+ "vue-tsc": "3.0.6"
25
55
  }
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.7.1",
35
- "jose": "6.1.3"
36
- },
37
- "peerDependencies": {
38
- "nuxt": "^3.0.0 || ^4.0.0",
39
- "vue": "^3.0.0"
40
- },
41
- "devDependencies": {
42
- "@nuxt/devtools": "2.6.3",
43
- "@nuxt/eslint-config": "1.9.0",
44
- "@nuxt/kit": "4.0.3",
45
- "@nuxt/module-builder": "1.0.2",
46
- "@nuxt/schema": "4.0.3",
47
- "@nuxt/test-utils": "3.19.2",
48
- "@types/node": "latest",
49
- "changelogen": "0.6.2",
50
- "nuxt": "4.0.3",
51
- "typescript": "5.9.2",
52
- "unbuild": "3.6.1",
53
- "vitest": "3.2.4",
54
- "vue-tsc": "3.0.6"
55
- }
56
56
  }