@meistrari/auth-nuxt 2.1.0 → 2.1.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": "2.1.0",
4
+ "version": "2.1.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -139,7 +139,7 @@ export function useTelaApplicationAuth() {
139
139
  if (!refreshTokenCookie.value) {
140
140
  throw new RefreshTokenExpiredError();
141
141
  }
142
- const { accessToken, refreshToken: refreshToken2, user, organization } = await authClient.application.refreshAccessToken();
142
+ const { accessToken, refreshToken: refreshToken2, user, organization } = await authClient.application.refreshAccessToken(refreshTokenCookie.value);
143
143
  accessTokenCookie.value = accessToken;
144
144
  refreshTokenCookie.value = refreshToken2;
145
145
  state.user.value = user;
@@ -167,7 +167,7 @@ export function useTelaApplicationAuth() {
167
167
  return organizations;
168
168
  }
169
169
  async function switchOrganization(organizationId) {
170
- const { accessToken, refreshToken: refreshToken2, user, organization } = await authClient.application.switchOrganization(organizationId);
170
+ const { accessToken, refreshToken: refreshToken2, user, organization } = await authClient.application.switchOrganization(organizationId, accessTokenCookie.value);
171
171
  accessTokenCookie.value = accessToken;
172
172
  refreshTokenCookie.value = refreshToken2;
173
173
  state.user.value = user;
@@ -1,8 +1,8 @@
1
1
  import { defineNuxtPlugin, useCookie, useRuntimeConfig } from "#app";
2
- import { isTokenExpired } from "@meistrari/auth-core";
2
+ import { isTokenExpired, RefreshTokenExpiredError } from "@meistrari/auth-core";
3
+ import { watch } from "vue";
3
4
  import { useApplicationSessionState } from "../composables/state.js";
4
5
  import { createNuxtAuthClient } from "../shared.js";
5
- import { watch } from "vue";
6
6
  const SEVEN_DAYS = 60 * 60 * 24 * 7;
7
7
  const FIFTEEN_MINUTES = 60 * 15;
8
8
  const TWO_MINUTES = 2 * 60 * 1e3;
@@ -50,15 +50,16 @@ export default defineNuxtPlugin({
50
50
  const authClient = createNuxtAuthClient(appConfig.apiUrl, () => null, () => refreshTokenCookie.value ?? null);
51
51
  let tokenRefreshInterval = null;
52
52
  let isRefreshing = false;
53
- let retryCount = 0;
54
- const MAX_RETRIES = 3;
55
53
  async function refreshToken() {
56
54
  if (isRefreshing) {
57
55
  return;
58
56
  }
59
57
  isRefreshing = true;
60
58
  try {
61
- const { accessToken, refreshToken: refreshToken2, user, organization } = await authClient.application.refreshAccessToken();
59
+ if (!refreshTokenCookie.value) {
60
+ throw new RefreshTokenExpiredError();
61
+ }
62
+ const { accessToken, refreshToken: refreshToken2, user, organization } = await authClient.application.refreshAccessToken(refreshTokenCookie.value);
62
63
  accessTokenCookie.value = accessToken;
63
64
  refreshTokenCookie.value = refreshToken2;
64
65
  state.user.value = user;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-nuxt",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -31,7 +31,7 @@
31
31
  "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build"
32
32
  },
33
33
  "dependencies": {
34
- "@meistrari/auth-core": "1.7.0",
34
+ "@meistrari/auth-core": "1.7.1",
35
35
  "jose": "6.1.3"
36
36
  },
37
37
  "peerDependencies": {