@authup/client-web-nuxt 1.0.0-beta.51 → 1.0.0-beta.53
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
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",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
StoreAuthStatus,
|
|
2
3
|
clearAuthorizationRequest,
|
|
3
4
|
injectStore,
|
|
4
5
|
loadAuthorizationRequest,
|
|
@@ -115,7 +116,7 @@ export class RoutingInterceptor {
|
|
|
115
116
|
if (!this.hasLoggedInCondition(route)) {
|
|
116
117
|
return true;
|
|
117
118
|
}
|
|
118
|
-
return
|
|
119
|
+
return this.storeRefs.status.value === StoreAuthStatus.AUTHENTICATED;
|
|
119
120
|
}
|
|
120
121
|
hasLoggedOutCondition(route) {
|
|
121
122
|
return route.matched.some(
|
|
@@ -126,7 +127,7 @@ export class RoutingInterceptor {
|
|
|
126
127
|
if (!this.hasLoggedOutCondition(route)) {
|
|
127
128
|
return true;
|
|
128
129
|
}
|
|
129
|
-
return
|
|
130
|
+
return this.storeRefs.status.value !== StoreAuthStatus.AUTHENTICATED;
|
|
130
131
|
}
|
|
131
132
|
hasPermissionCondition(route) {
|
|
132
133
|
return route.matched.some(
|
|
@@ -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.
|
|
4
|
+
"version": "1.0.0-beta.53",
|
|
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.
|
|
34
|
-
"@authup/client-web-kit": "^1.0.0-beta.
|
|
35
|
-
"@authup/kit": "^1.0.0-beta.
|
|
33
|
+
"@authup/access": "^1.0.0-beta.53",
|
|
34
|
+
"@authup/client-web-kit": "^1.0.0-beta.53",
|
|
35
|
+
"@authup/kit": "^1.0.0-beta.53",
|
|
36
36
|
"@nuxt/kit": "^4.0.0",
|
|
37
37
|
"pathtrace": "^2.2.0",
|
|
38
38
|
"smob": "^1.6.1"
|