@jskit-ai/auth-web 0.2.45 → 0.2.46
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/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
- Up to medium width, the account control's
|
|
5
|
+
- Up to medium width, the account control's name begins with the initials its avatar shows: "AN ana.ferreira" for ana.ferreira without a picture, the person's name alone with one. That round button is named by its aria-label, and WCAG 2.5.3 Label in Name asks that a control's name hold the text it shows, the words a person using speech input says to press it (axe `label-content-name-mismatch`). Its avatar is hidden from assistive technology (`aria-hidden="true"`), since the name says whose account it is; hiding it alone, as 0.2.45 did, left the finding, as axe counts every word drawn on the screen. On wider windows the control's name is the text it shows, as before.
|
|
6
6
|
- Email change over HTTP: `POST /api/email-change` (signed in, `{ email, password }`) asks for it and `POST /api/email-change/confirm` (public, `{ token }`) uses the link, each limited per address by `config.auth.rateLimits.emailChange` (5 a minute) and `emailChangeConfirm` (10 a minute). The page the link opens is `DefaultEmailChangeView` (`./client/views/DefaultEmailChangeView`, route component `auth-email-change`, the `auth.email-change` route at `/auth/email-change`, public, registered by an application's own page as the sign-in, reset and sign-out pages are): it confirms the link once, takes the token out of the address, and says the new email or why the link was refused (`jskit.auth.emailChange.*`).
|
|
7
7
|
- `POST /api/login/pass` hands `signInWithPass` the request that posted the pass, so local auth keeps the session's address and browser.
|
|
8
8
|
- Its tests name `APP_ENV`, which the auth providers now read in place of `NODE_ENV`; the setup-code field is asked for by a staging or production server.
|
package/fixtures/sign-in/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createApp, h, ref } from "vue";
|
|
1
|
+
import { createApp, defineAsyncComponent, h, ref } from "vue";
|
|
2
2
|
import { createPinia } from "pinia";
|
|
3
|
-
import { createRouter, createWebHistory, RouterView } from "vue-router";
|
|
3
|
+
import { createRouter, createWebHistory, RouterView, useRoute } from "vue-router";
|
|
4
4
|
import { QueryClient, VueQueryPlugin } from "@tanstack/vue-query";
|
|
5
5
|
import "vuetify/styles";
|
|
6
6
|
import "@jskit-ai/material-web/client/material.css";
|
|
@@ -84,7 +84,8 @@ const SecondFactorPage = {
|
|
|
84
84
|
]);
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
// An application's console: its refund route asks for a code proved
|
|
87
|
+
// An application's console, in the shell's layout as an app's screens are: its refund route asks for a code proved
|
|
88
|
+
// within five minutes, through the step-up dialog, over the page the shell makes inert while the dialog is open.
|
|
88
89
|
const ConsolePage = {
|
|
89
90
|
setup() {
|
|
90
91
|
const { open, run, verified, cancel } = useSecondFactorStepUp();
|
|
@@ -124,7 +125,7 @@ const router = createRouter({
|
|
|
124
125
|
{ path: "/", redirect: "/home" },
|
|
125
126
|
{ path: "/home", component: HomePage },
|
|
126
127
|
{ path: "/account/second-factor", component: SecondFactorPage },
|
|
127
|
-
{ path: "/console", component: ConsolePage },
|
|
128
|
+
{ path: "/console", component: ConsolePage, meta: { shell: true } },
|
|
128
129
|
{ path: "/auth/login", component: DefaultLoginView },
|
|
129
130
|
{ path: "/auth/reset-password", component: DefaultResetPasswordView },
|
|
130
131
|
{ path: "/auth/signout", component: DefaultSignOutView },
|
|
@@ -137,7 +138,19 @@ const router = createRouter({
|
|
|
137
138
|
{ path: "/auth/pattern/signout", component: PatternSignOutPage }
|
|
138
139
|
]
|
|
139
140
|
});
|
|
140
|
-
|
|
141
|
+
// A page in the shell's layout (`meta.shell`) has the layout's main; the others have a plain one. Only the console
|
|
142
|
+
// page is in the layout, so only it loads the layout: the sign-in pages load what they did before.
|
|
143
|
+
const ShellLayout = defineAsyncComponent(() => import("@jskit-ai/shell-web/client/components/ShellLayout"));
|
|
144
|
+
const app = createApp({
|
|
145
|
+
setup() {
|
|
146
|
+
const route = useRoute();
|
|
147
|
+
return () => h(components.VApp, null, {
|
|
148
|
+
default: () => route.meta.shell
|
|
149
|
+
? h(ShellLayout, { title: "Console" }, { default: () => h(RouterView) })
|
|
150
|
+
: h(components.VMain, null, { default: () => h(RouterView) })
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
});
|
|
141
154
|
const pinia = createPinia();
|
|
142
155
|
app.provide(SHELL_WEB_PLACEMENT_RUNTIME_KEY, placement);
|
|
143
156
|
app.provide(SHELL_WEB_ERROR_RUNTIME_KEY, errorRuntime);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/auth-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.46",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@jskit-ai/auth-core": "0.2.31",
|
|
37
37
|
"@jskit-ai/http-runtime": "0.2.27",
|
|
38
38
|
"@jskit-ai/kernel": "0.2.27",
|
|
39
|
-
"@jskit-ai/shell-web": "0.2.
|
|
39
|
+
"@jskit-ai/shell-web": "0.2.40",
|
|
40
40
|
"@tanstack/vue-query": "^5.90.5",
|
|
41
41
|
"pinia": "^4.0.3",
|
|
42
42
|
"vue": "^3.5.44",
|
|
@@ -11,8 +11,10 @@ const { t } = useJskitText();
|
|
|
11
11
|
const { context: shellPlacementContext } = useWebPlacementContext();
|
|
12
12
|
// On expanded windows the activator is a pill with the name beside the avatar, the name ending in an ellipsis past
|
|
13
13
|
// 12rem; on medium and compact windows, where the app bar's title and actions need the room, it is a round icon
|
|
14
|
-
// button around the avatar, named by its aria-label.
|
|
15
|
-
//
|
|
14
|
+
// button around the avatar, named by its aria-label. A control's name holds the text it shows (WCAG 2.5.3 Label in
|
|
15
|
+
// Name), the words a person using speech input says to press it, and every word drawn on the screen counts, hidden
|
|
16
|
+
// from assistive technology or not; so without a picture that name begins with the initials the avatar shows,
|
|
17
|
+
// "AN ana.ferreira". The avatar itself stays hidden from assistive technology: the name says whose account it is.
|
|
16
18
|
const { isExpanded, isLarge } = useShellWindowSizeClass();
|
|
17
19
|
const showsName = computed(() => isExpanded.value || isLarge.value);
|
|
18
20
|
|
|
@@ -61,6 +63,8 @@ const initials = computed(() => {
|
|
|
61
63
|
return text.slice(0, 2).toUpperCase();
|
|
62
64
|
});
|
|
63
65
|
|
|
66
|
+
const compactName = computed(() => (avatarUrl.value ? displayName.value : `${initials.value} ${displayName.value}`));
|
|
67
|
+
|
|
64
68
|
const placementContext = computed(() => {
|
|
65
69
|
return {
|
|
66
70
|
auth: auth.authState,
|
|
@@ -84,7 +88,7 @@ const placementContext = computed(() => {
|
|
|
84
88
|
</v-avatar>
|
|
85
89
|
<span class="auth-profile-widget__name ml-2 text-body-medium">{{ displayName }}</span>
|
|
86
90
|
</v-btn>
|
|
87
|
-
<v-btn v-else v-bind="props" icon variant="text" class="auth-profile-widget__activator" :aria-label="
|
|
91
|
+
<v-btn v-else v-bind="props" icon variant="text" class="auth-profile-widget__activator" :aria-label="compactName">
|
|
88
92
|
<v-avatar size="32" color="primary" variant="tonal" aria-hidden="true">
|
|
89
93
|
<v-img v-if="avatarUrl" :src="avatarUrl" cover />
|
|
90
94
|
<span v-else class="text-body-small font-weight-medium">{{ initials }}</span>
|
|
@@ -78,7 +78,7 @@ test("auth profile activator keeps Material 3's 48dp touch target without a fixe
|
|
|
78
78
|
// Without the name, up to medium width, the activator is an icon button, so its state layer is a circle round the
|
|
79
79
|
// avatar; the name shows on expanded windows only, through the shell's window size classes.
|
|
80
80
|
assert.match(widgetSource, /const showsName = computed\(\(\) => isExpanded\.value \|\| isLarge\.value\);/u);
|
|
81
|
-
assert.match(widgetSource, /<v-btn v-else v-bind="props" icon variant="text" class="auth-profile-widget__activator" :aria-label="
|
|
81
|
+
assert.match(widgetSource, /<v-btn v-else v-bind="props" icon variant="text" class="auth-profile-widget__activator" :aria-label="compactName">/u);
|
|
82
82
|
// material-web gives every default-size button a 48dp touch target around its 40dp body; a fixed height would
|
|
83
83
|
// make the button itself taller than Material 3 draws it.
|
|
84
84
|
assert.doesNotMatch(widgetSource, /min-height/u);
|
|
@@ -190,7 +190,14 @@ test("removing the authenticator takes a code or a recovery code, shows a wait b
|
|
|
190
190
|
await finish(api);
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
// Whether every part of the shell's page around the console (its app bar and main at least) is inert, as it is while
|
|
194
|
+
// the step-up dialog is open, or else every part live.
|
|
195
|
+
async function shellPageIs(page, inert) {
|
|
196
|
+
const parts = await page.evaluate(() => [...document.querySelectorAll("[data-shell-page]")].map((part) => part.inert));
|
|
197
|
+
return parts.length >= 2 && parts.every((part) => part === inert);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
test("a route that asks for a fresh code opens the step-up dialog over an inert page, runs again after the code, and Escape cancels it, focus returning to the control each time", options, async () => {
|
|
194
201
|
const api = await openApp({
|
|
195
202
|
"POST /api/console/refund": [REQUIRED, { json: { refunded: true } }, REQUIRED],
|
|
196
203
|
"POST /api/second-factor/verify": [
|
|
@@ -205,6 +212,7 @@ test("a route that asks for a fresh code opens the step-up dialog, runs again af
|
|
|
205
212
|
const dialog = page.getByRole("dialog", { name: "Confirm it's you" });
|
|
206
213
|
await expect(dialog.getByRole("heading", { name: "Confirm it's you" })).toBeVisible();
|
|
207
214
|
await expect(dialog.getByLabel("6-digit code")).toBeFocused();
|
|
215
|
+
assert.ok(await shellPageIs(page, true), "the shell's app bar and main are inert behind the dialog");
|
|
208
216
|
await fitsTheScreen(page);
|
|
209
217
|
await page.keyboard.type("000000");
|
|
210
218
|
await page.keyboard.press("Enter");
|
|
@@ -213,15 +221,18 @@ test("a route that asks for a fresh code opens the step-up dialog, runs again af
|
|
|
213
221
|
await page.keyboard.press("Enter");
|
|
214
222
|
await expect(page.getByTestId("console-outcome")).toHaveText("Refunded");
|
|
215
223
|
await expect(dialog).toBeHidden();
|
|
216
|
-
// Focus is back on the control that sent the request, after a code as after cancelling.
|
|
224
|
+
// Focus is back on the control that sent the request, after a code as after cancelling, on a live page.
|
|
217
225
|
await expect(page.getByRole("button", { name: "Refund" })).toBeFocused();
|
|
226
|
+
assert.ok(await shellPageIs(page, false), "the page is live again");
|
|
218
227
|
|
|
219
228
|
await page.keyboard.press("Enter");
|
|
220
229
|
await expect(dialog.getByLabel("6-digit code")).toBeFocused();
|
|
230
|
+
assert.ok(await shellPageIs(page, true), "the page is inert behind the dialog again");
|
|
221
231
|
await page.keyboard.press("Escape");
|
|
222
232
|
await expect(dialog).toBeHidden();
|
|
223
233
|
await expect(page.getByTestId("console-outcome")).toHaveText("Refund failed: Confirm it's you with a code from your authenticator app.");
|
|
224
234
|
await expect(page.getByRole("button", { name: "Refund" })).toBeFocused();
|
|
235
|
+
assert.ok(await shellPageIs(page, false), "the page is live after Escape");
|
|
225
236
|
|
|
226
237
|
assert.equal(bodiesOf(api, "POST /api/console/refund").length, 3);
|
|
227
238
|
assert.deepEqual(bodiesOf(api, "POST /api/second-factor/verify"), [{ code: "000000" }, { code: "123456" }]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import process from "node:process";
|
|
3
4
|
import { after, before, test } from "node:test";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -6,6 +7,8 @@ import { chromium, expect } from "@playwright/test";
|
|
|
6
7
|
import { createChromiumLaunchOptions, startViteFixture, stopProcess } from "../../../tooling/testUtils/browserFixture.mjs";
|
|
7
8
|
|
|
8
9
|
const RUN = process.env.JSKIT_AUTH_WEB_BROWSER_INTEGRATION === "1";
|
|
10
|
+
// axe-core as the page runs it, to check a rule the way axe reports it on an app's screens.
|
|
11
|
+
const AXE_PATH = createRequire(import.meta.url).resolve("axe-core/axe.min.js");
|
|
9
12
|
const options = { skip: !RUN, timeout: 120_000 };
|
|
10
13
|
const GUARD_EVALUATOR_KEY = "__JSKIT_WEB_SHELL_GUARD_EVALUATOR__";
|
|
11
14
|
const CAPABILITIES = {
|
|
@@ -578,32 +581,28 @@ test("the account control is the avatar alone up to medium width and truncates a
|
|
|
578
581
|
await finish(api);
|
|
579
582
|
});
|
|
580
583
|
|
|
581
|
-
// WCAG 2.5.3 Label in Name: a control's name holds the text it shows
|
|
582
|
-
//
|
|
583
|
-
//
|
|
584
|
-
//
|
|
585
|
-
test("the account control's name holds
|
|
584
|
+
// WCAG 2.5.3 Label in Name: a control's name holds the text it shows, the words a person using speech input says to
|
|
585
|
+
// press it. Up to medium width the account control is a round button named by its aria-label, and without a picture
|
|
586
|
+
// its avatar shows the initials, "AN" for ana.ferreira. axe's label-content-name-mismatch counts every word drawn on
|
|
587
|
+
// the screen, aria-hidden or not, so the name begins with the initials: "AN ana.ferreira".
|
|
588
|
+
test("the account control's name holds the initials it shows on a phone and a tablet: WCAG 2.5.3 (axe label-content-name-mismatch)", options, async () => {
|
|
586
589
|
const name = "ana.ferreira";
|
|
587
|
-
const words = (text) => text.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
588
590
|
for (const viewport of [{ width: 390, height: 844 }, { width: 768, height: 1024 }]) {
|
|
589
591
|
const at = `${viewport.width}px`;
|
|
590
592
|
const api = await openApp({ session: { ...SIGNED_IN, username: name }, viewport });
|
|
591
593
|
const { page } = api;
|
|
592
594
|
await page.goto("/home");
|
|
593
|
-
const control = page.getByRole("button", { name
|
|
594
|
-
await expect(control, at).toBeVisible();
|
|
595
|
+
const control = page.getByRole("button", { name: /ana\.ferreira/u });
|
|
595
596
|
await expect(control, `${at}: it shows the initials`).toHaveText("AN");
|
|
596
|
-
|
|
597
|
-
const
|
|
598
|
-
const
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
if (!node.parentElement.closest("[aria-hidden=true]")) texts.push(node.textContent);
|
|
602
|
-
}
|
|
603
|
-
return texts.join(" ");
|
|
597
|
+
await page.addScriptTag({ path: AXE_PATH });
|
|
598
|
+
const audit = await control.evaluate(async (button) => {
|
|
599
|
+
const results = await window.axe.run(button, { runOnly: { type: "rule", values: ["label-content-name-mismatch"] } });
|
|
600
|
+
const nodes = (outcome) => outcome.flatMap((rule) => rule.nodes.map((node) => node.failureSummary ?? node.html));
|
|
601
|
+
return { violations: nodes(results.violations), incomplete: nodes(results.incomplete), passed: nodes(results.passes).length };
|
|
604
602
|
});
|
|
605
|
-
|
|
606
|
-
assert.
|
|
603
|
+
assert.deepEqual({ violations: audit.violations, incomplete: audit.incomplete }, { violations: [], incomplete: [] }, at);
|
|
604
|
+
assert.equal(audit.passed, 1, `${at}: axe checked the control's name against what it shows`);
|
|
605
|
+
await expect(control, at).toHaveAccessibleName(`AN ${name}`);
|
|
607
606
|
await finish(api);
|
|
608
607
|
}
|
|
609
608
|
});
|