@jskit-ai/auth-web 0.1.196 → 0.1.198

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/auth-web",
3
- "version": "0.1.196",
3
+ "version": "0.1.198",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -25,10 +25,10 @@
25
25
  "@mdi/js": "^7.4.47"
26
26
  },
27
27
  "peerDependencies": {
28
- "@jskit-ai/auth-core": "0.1.194",
29
- "@jskit-ai/http-runtime": "0.1.194",
30
- "@jskit-ai/kernel": "0.1.196",
31
- "@jskit-ai/shell-web": "0.1.200",
28
+ "@jskit-ai/auth-core": "0.1.196",
29
+ "@jskit-ai/http-runtime": "0.1.196",
30
+ "@jskit-ai/kernel": "0.1.198",
31
+ "@jskit-ai/shell-web": "0.1.202",
32
32
  "@tanstack/vue-query": "^5.90.5",
33
33
  "pinia": "^3.0.4",
34
34
  "vue": "^3.5.13",
@@ -60,6 +60,10 @@ a user as a side effect.
60
60
  - Public auth routes do not require an existing session.
61
61
  - Protected routes use the framework auth policy rather than page-local checks.
62
62
  - Login, sign-out, and reset views use the public auth components/composables.
63
+ - A custom login view must preserve the default view's initial session check:
64
+ already authenticated people return to the validated requested destination.
65
+ Process incoming login callbacks before that redirect, and keep signed-out
66
+ people on the login form. This also covers managed preview identity changes.
63
67
  - Profile placements are conditional on the current authenticated state.
64
68
  - Transient mutation failures use the application toast; initial load failures
65
69
  remain in the affected surface.
@@ -81,6 +85,8 @@ placements, and post-auth destinations while retaining the runtime contracts.
81
85
 
82
86
  Exercise failed and successful login, sign-out, reset, protected navigation,
83
87
  keyboard interaction, warm-cache return navigation, and browser refresh.
88
+ Open the login route with an existing authenticated session and confirm it
89
+ returns to the requested screen; repeat signed out and confirm the form remains.
84
90
 
85
91
  ## Avoid
86
92
 
@@ -55,6 +55,44 @@ function createMinimalLoginViewState(requestedReturnTo = "/") {
55
55
  };
56
56
  }
57
57
 
58
+ for (const authenticated of [true, false]) {
59
+ test(`login initialization ${authenticated ? "redirects an existing session" : "keeps the signed-out form"}`, async (t) => {
60
+ const state = createMinimalLoginViewState("/w/acme/bookings?date=2026-09-16");
61
+ const destinations = [];
62
+ const originalWindow = globalThis.window;
63
+ globalThis.window = {
64
+ location: {
65
+ href: "https://example.com/auth/login",
66
+ replace: (path) => destinations.push(path)
67
+ }
68
+ };
69
+ t.after(() => {
70
+ if (originalWindow === undefined) delete globalThis.window;
71
+ else globalThis.window = originalWindow;
72
+ clearAuthCsrfTokenCache();
73
+ });
74
+ const fetch = t.mock.method(globalThis, "fetch", async (url) => {
75
+ assert.equal(url, "/api/session");
76
+ return createJsonResponse({ authenticated, csrfToken: "csrf-session" });
77
+ });
78
+ const actions = useLoginViewActions({
79
+ state,
80
+ validation: {},
81
+ queryClient: {
82
+ fetchQuery: ({ queryFn }) => queryFn()
83
+ },
84
+ errorRuntime: { report: (entry) => assert.fail(entry.message) }
85
+ });
86
+
87
+ await actions.initializeOnMounted();
88
+
89
+ assert.equal(fetch.mock.callCount(), 1);
90
+ assert.deepEqual(destinations, authenticated ? [state.requestedReturnTo.value] : []);
91
+ assert.equal(state.loading.value, false);
92
+ assert.equal(state.errorMessage.value, "");
93
+ });
94
+ }
95
+
58
96
  test("useLoginViewActions preserves the intended destination when starting OAuth sign-in", () => {
59
97
  const state = createMinimalLoginViewState("/w/acme/workouts/2026-05-07?tab=chart");
60
98
  const assignedTargets = [];