@authup/client-web-nuxt 1.0.0-beta.51 → 1.0.0-beta.52

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": "@authup/client-web-nuxt",
3
3
  "configKey": "authup",
4
- "version": "1.0.0-beta.51",
4
+ "version": "1.0.0-beta.52",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -43,6 +43,7 @@ const module$1 = defineNuxtModule({
43
43
  options2.references.push({ path: template.dst });
44
44
  });
45
45
  addPlugin(resolver.resolve("./runtime/plugins/kit"));
46
+ addPlugin(resolver.resolve("./runtime/plugins/session-expiry"));
46
47
  addPlugin(resolver.resolve("./runtime/plugins/root"));
47
48
  addRouteMiddleware({
48
49
  name: "authup",
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Redirect an idle user to the login route when a background token refresh
3
+ * fails (SESSION_EXPIRED). The route middleware already handles this on the
4
+ * next navigation; this covers the case where the session dies while the user
5
+ * sits on an authenticated page with no navigation to trigger the interceptor.
6
+ */
7
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
8
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import { StoreDispatcherEventName, injectStoreDispatcher } from "@authup/client-web-kit";
2
+ import { defineNuxtPlugin, useRouter, useRuntimeConfig } from "#imports";
3
+ import { RouteMetaKey } from "../constants.js";
4
+ export default defineNuxtPlugin({
5
+ name: "authup:session-expiry",
6
+ dependsOn: ["authup:kit"],
7
+ setup(ctx) {
8
+ if (import.meta.server) {
9
+ return;
10
+ }
11
+ const router = useRouter();
12
+ const runtimeOptions = useRuntimeConfig().public.authup;
13
+ const loginRoute = runtimeOptions.loginRoute || "/login";
14
+ const dispatcher = injectStoreDispatcher(ctx.vueApp);
15
+ dispatcher.on(StoreDispatcherEventName.SESSION_EXPIRED, () => {
16
+ const route = router.currentRoute.value;
17
+ if (route.path === loginRoute) {
18
+ return;
19
+ }
20
+ const requiresLogin = route.matched.some(
21
+ (matched) => !!matched.meta[RouteMetaKey.REQUIRE_LOGGED_IN]
22
+ );
23
+ if (!requiresLogin) {
24
+ return;
25
+ }
26
+ router.push({
27
+ path: loginRoute,
28
+ query: { redirect: route.fullPath }
29
+ }).catch(() => {
30
+ });
31
+ });
32
+ }
33
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@authup/client-web-nuxt",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.51",
4
+ "version": "1.0.0-beta.52",
5
5
  "description": "Nuxt module for the authup ecosystem",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -30,9 +30,9 @@
30
30
  "node": "^22.13.0 || ^23.5.0 || >=24.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@authup/access": "^1.0.0-beta.51",
34
- "@authup/client-web-kit": "^1.0.0-beta.51",
35
- "@authup/kit": "^1.0.0-beta.51",
33
+ "@authup/access": "^1.0.0-beta.52",
34
+ "@authup/client-web-kit": "^1.0.0-beta.52",
35
+ "@authup/kit": "^1.0.0-beta.52",
36
36
  "@nuxt/kit": "^4.0.0",
37
37
  "pathtrace": "^2.2.0",
38
38
  "smob": "^1.6.1"