@celestia-island/hikari 0.55.468 → 0.55.470
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/types/components/HkLoginFlow.d.ts +43 -1
- package/dist/types/components/HkMfaVerifyCard.d.ts +54 -0
- package/package.json +1 -1
- package/src/components/HkLoginFlow.test.tsx +112 -0
- package/src/components/HkLoginFlow.tsx +27 -0
- package/src/components/HkMfaVerifyCard.test.ts +129 -0
- package/src/components/HkMfaVerifyCard.tsx +48 -0
|
@@ -34,6 +34,13 @@ export interface HkLoginCredentialsChannel {
|
|
|
34
34
|
* opening card must not ask for it (2026-11 user direction). */
|
|
35
35
|
passwordField?: boolean;
|
|
36
36
|
submitLabel?: string;
|
|
37
|
+
/** Extra guard over the channel's WHOLE credentials body: the fields
|
|
38
|
+
* and the submit stay disabled while the host's own gate is closed
|
|
39
|
+
* (erp's register body: the anti-abuse challenge is still being
|
|
40
|
+
* solved). Default false — the built-in empty-field check is then the
|
|
41
|
+
* only guard. Per channel on purpose: one body may be gated while
|
|
42
|
+
* the other is always submittable. */
|
|
43
|
+
disabled?: boolean;
|
|
37
44
|
/** Alternative sign-in rows under the form (rendered only when
|
|
38
45
|
* non-empty; an empty list omits the whole methods block instead of
|
|
39
46
|
* padding a dead strip). */
|
|
@@ -91,6 +98,9 @@ export type HkLoginChannel = HkLoginCredentialsChannel | HkLoginSsoChannel;
|
|
|
91
98
|
* - `sso-click(channel)` — the primary sso row was picked.
|
|
92
99
|
* - `verify(kind, proof)` / `verify-resend` / `verify-back` — the MFA
|
|
93
100
|
* body's events, re-emitted one level up.
|
|
101
|
+
* - `verifyMethods` — alternative sign-in rows on the verify step (the
|
|
102
|
+
* third-party providers the account can still sign in through);
|
|
103
|
+
* `verify-method-select(key)` re-emits a picked row.
|
|
94
104
|
*
|
|
95
105
|
* Card grammar (2026-11-24 user direction, the reason this file looks
|
|
96
106
|
* the way it does): *"where the content can change inside the card, do
|
|
@@ -234,6 +244,19 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
|
|
|
234
244
|
type: StringConstructor;
|
|
235
245
|
default: undefined;
|
|
236
246
|
};
|
|
247
|
+
/** Alternative sign-in rows on the verify step: the third-party
|
|
248
|
+
* providers the account can still sign in through (a linked OAuth
|
|
249
|
+
* identity). A row is not a factor — see HkMfaVerifyCard.methods.
|
|
250
|
+
* Rendered only when non-empty. */
|
|
251
|
+
verifyMethods: {
|
|
252
|
+
type: PropType<readonly HkAuthChannelListEntry[]>;
|
|
253
|
+
default: () => never[];
|
|
254
|
+
};
|
|
255
|
+
/** Divider text above the verify step's rows; consumer-localized. */
|
|
256
|
+
verifyMethodsDivider: {
|
|
257
|
+
type: StringConstructor;
|
|
258
|
+
default: undefined;
|
|
259
|
+
};
|
|
237
260
|
}>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
238
261
|
"update:modelValue": (_key: string) => true;
|
|
239
262
|
"account-submit": (_channel: string, _username: string, _password: string) => true;
|
|
@@ -242,6 +265,9 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
|
|
|
242
265
|
verify: (_kind: HkMfaFactor, _proof: string) => true;
|
|
243
266
|
"verify-resend": () => true;
|
|
244
267
|
"verify-back": () => true;
|
|
268
|
+
/** A third-party sign-in row was picked on the verify step — the
|
|
269
|
+
* provider's key, as `method-select` carries on the account step. */
|
|
270
|
+
"verify-method-select": (_key: string) => true;
|
|
245
271
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
246
272
|
/** The deployment's sign-in channels. One entry renders a plain
|
|
247
273
|
* card (no segment group); two entries render the pill group. */
|
|
@@ -336,14 +362,28 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
|
|
|
336
362
|
type: StringConstructor;
|
|
337
363
|
default: undefined;
|
|
338
364
|
};
|
|
365
|
+
/** Alternative sign-in rows on the verify step: the third-party
|
|
366
|
+
* providers the account can still sign in through (a linked OAuth
|
|
367
|
+
* identity). A row is not a factor — see HkMfaVerifyCard.methods.
|
|
368
|
+
* Rendered only when non-empty. */
|
|
369
|
+
verifyMethods: {
|
|
370
|
+
type: PropType<readonly HkAuthChannelListEntry[]>;
|
|
371
|
+
default: () => never[];
|
|
372
|
+
};
|
|
373
|
+
/** Divider text above the verify step's rows; consumer-localized. */
|
|
374
|
+
verifyMethodsDivider: {
|
|
375
|
+
type: StringConstructor;
|
|
376
|
+
default: undefined;
|
|
377
|
+
};
|
|
339
378
|
}>> & Readonly<{
|
|
340
379
|
"onUpdate:modelValue"?: ((_key: string) => any) | undefined;
|
|
341
380
|
onVerify?: ((_kind: "password" | "passkey" | "totp" | "sms", _proof: string) => any) | undefined;
|
|
342
|
-
"onAccount-submit"?: ((_channel: string, _username: string, _password: string) => any) | undefined;
|
|
343
381
|
"onMethod-select"?: ((_channel: string, _key: string) => any) | undefined;
|
|
382
|
+
"onAccount-submit"?: ((_channel: string, _username: string, _password: string) => any) | undefined;
|
|
344
383
|
"onSso-click"?: ((_channel: string) => any) | undefined;
|
|
345
384
|
"onVerify-resend"?: (() => any) | undefined;
|
|
346
385
|
"onVerify-back"?: (() => any) | undefined;
|
|
386
|
+
"onVerify-method-select"?: ((_key: string) => any) | undefined;
|
|
347
387
|
}>, {
|
|
348
388
|
step: "verify" | "account";
|
|
349
389
|
title: string;
|
|
@@ -359,5 +399,7 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
|
|
|
359
399
|
verifyAccountName: string;
|
|
360
400
|
verifyLoading: boolean;
|
|
361
401
|
verifyResending: boolean;
|
|
402
|
+
verifyMethods: readonly HkAuthChannelListEntry[];
|
|
403
|
+
verifyMethodsDivider: string;
|
|
362
404
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
363
405
|
export default HkLoginFlow;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PropType } from "vue";
|
|
2
|
+
import { type HkAuthChannelListEntry } from "./HkAuthChannelList";
|
|
2
3
|
import "./HkMfaVerifyCard.scss";
|
|
3
4
|
/** Every second-factor kind this card can drive. The first three are the
|
|
4
5
|
* classic second factors a backend announces after the primary login;
|
|
@@ -68,6 +69,14 @@ export declare function hkMfaVerifySubtitle(t: HkMfaTranslate, options?: {
|
|
|
68
69
|
* "one more verification" wording. The card re-selects and clears its
|
|
69
70
|
* fields whenever the announced set or the proven factor changes.
|
|
70
71
|
*
|
|
72
|
+
* Alternative sign-in rows (`methods`) are a SEPARATE lane from the
|
|
73
|
+
* factors: a host whose ladder also accepts a linked third-party
|
|
74
|
+
* identity for this account lists the providers under the proof field,
|
|
75
|
+
* and picking one emits `method-select(key)` instead of `verify` — the
|
|
76
|
+
* provider's own authorization round trip is the proof, and it happens
|
|
77
|
+
* on the host's side. The rows share the credentials card's channel
|
|
78
|
+
* list, so a provider reads the same on both steps.
|
|
79
|
+
*
|
|
71
80
|
* i18n: every visible string defaults to the `hikari::mfaVerify.*` locales
|
|
72
81
|
* (11 languages ship with the card); `title` / `subtitle` overrides win
|
|
73
82
|
* when a host needs its own wording. `{name}` / `{proven}` placeholders in
|
|
@@ -142,6 +151,26 @@ export declare const HkMfaVerifyCard: import("vue").DefineComponent<import("vue"
|
|
|
142
151
|
type: StringConstructor;
|
|
143
152
|
default: undefined;
|
|
144
153
|
};
|
|
154
|
+
/** Alternative sign-in rows UNDER the factor's proof field: the
|
|
155
|
+
* third-party providers this account can still sign in through (a
|
|
156
|
+
* linked OAuth identity — the erp "bind an existing account" ladder
|
|
157
|
+
* offers them beside password / totp). A row is NOT a factor: it
|
|
158
|
+
* never enters the picker and never emits `verify`; picking one
|
|
159
|
+
* hands the whole sign-in to the host (`method-select`), which
|
|
160
|
+
* usually leaves the page for the provider's authorization round
|
|
161
|
+
* trip. Rendered only when non-empty — the credentials card's
|
|
162
|
+
* `methods` rule: an empty list must not pad a dead strip under
|
|
163
|
+
* the submit. */
|
|
164
|
+
methods: {
|
|
165
|
+
type: PropType<readonly HkAuthChannelListEntry[]>;
|
|
166
|
+
default: () => never[];
|
|
167
|
+
};
|
|
168
|
+
/** Divider text above the rows; consumer-localized on purpose (the
|
|
169
|
+
* credentials channel's `methodsDivider` is the same contract). */
|
|
170
|
+
methodsDivider: {
|
|
171
|
+
type: StringConstructor;
|
|
172
|
+
default: undefined;
|
|
173
|
+
};
|
|
145
174
|
/** Focus the factor ON STAGE when the card mounts (the verify step
|
|
146
175
|
* just opened) and whenever the selected factor changes: the proof
|
|
147
176
|
* field for `totp` / `sms` (HkOtpInput owns that one) / `password`,
|
|
@@ -179,6 +208,8 @@ export declare const HkMfaVerifyCard: import("vue").DefineComponent<import("vue"
|
|
|
179
208
|
resend: () => true;
|
|
180
209
|
/** Abandon the step-up (back to the credentials card). */
|
|
181
210
|
back: () => true;
|
|
211
|
+
/** An alternative sign-in row was picked — the provider's key. */
|
|
212
|
+
"method-select": (_key: string) => true;
|
|
182
213
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
183
214
|
/** The factor kinds this account announced, server order. Raw
|
|
184
215
|
* strings are welcome — unknown kinds are filtered, and an emptied
|
|
@@ -236,6 +267,26 @@ export declare const HkMfaVerifyCard: import("vue").DefineComponent<import("vue"
|
|
|
236
267
|
type: StringConstructor;
|
|
237
268
|
default: undefined;
|
|
238
269
|
};
|
|
270
|
+
/** Alternative sign-in rows UNDER the factor's proof field: the
|
|
271
|
+
* third-party providers this account can still sign in through (a
|
|
272
|
+
* linked OAuth identity — the erp "bind an existing account" ladder
|
|
273
|
+
* offers them beside password / totp). A row is NOT a factor: it
|
|
274
|
+
* never enters the picker and never emits `verify`; picking one
|
|
275
|
+
* hands the whole sign-in to the host (`method-select`), which
|
|
276
|
+
* usually leaves the page for the provider's authorization round
|
|
277
|
+
* trip. Rendered only when non-empty — the credentials card's
|
|
278
|
+
* `methods` rule: an empty list must not pad a dead strip under
|
|
279
|
+
* the submit. */
|
|
280
|
+
methods: {
|
|
281
|
+
type: PropType<readonly HkAuthChannelListEntry[]>;
|
|
282
|
+
default: () => never[];
|
|
283
|
+
};
|
|
284
|
+
/** Divider text above the rows; consumer-localized on purpose (the
|
|
285
|
+
* credentials channel's `methodsDivider` is the same contract). */
|
|
286
|
+
methodsDivider: {
|
|
287
|
+
type: StringConstructor;
|
|
288
|
+
default: undefined;
|
|
289
|
+
};
|
|
239
290
|
/** Focus the factor ON STAGE when the card mounts (the verify step
|
|
240
291
|
* just opened) and whenever the selected factor changes: the proof
|
|
241
292
|
* field for `totp` / `sms` (HkOtpInput owns that one) / `password`,
|
|
@@ -269,9 +320,11 @@ export declare const HkMfaVerifyCard: import("vue").DefineComponent<import("vue"
|
|
|
269
320
|
onBack?: (() => any) | undefined;
|
|
270
321
|
onVerify?: ((_kind: "password" | "passkey" | "totp" | "sms", _proof: string) => any) | undefined;
|
|
271
322
|
onResend?: (() => any) | undefined;
|
|
323
|
+
"onMethod-select"?: ((_key: string) => any) | undefined;
|
|
272
324
|
}>, {
|
|
273
325
|
title: string;
|
|
274
326
|
loading: boolean;
|
|
327
|
+
methods: readonly HkAuthChannelListEntry[];
|
|
275
328
|
disabled: boolean;
|
|
276
329
|
subtitle: string;
|
|
277
330
|
autofocus: boolean;
|
|
@@ -282,5 +335,6 @@ export declare const HkMfaVerifyCard: import("vue").DefineComponent<import("vue"
|
|
|
282
335
|
accountName: string;
|
|
283
336
|
resending: boolean;
|
|
284
337
|
passkeyRetryHint: string;
|
|
338
|
+
methodsDivider: string;
|
|
285
339
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
286
340
|
export default HkMfaVerifyCard;
|
package/package.json
CHANGED
|
@@ -176,6 +176,59 @@ describe("HkLoginFlow — credentials channel", () => {
|
|
|
176
176
|
expect(c.querySelector(".hk-auth-channel-list")).toBeNull();
|
|
177
177
|
expect(c.querySelector(".hk-auth-channel-divider")).toBeNull();
|
|
178
178
|
});
|
|
179
|
+
|
|
180
|
+
it("keeps a channel's own gate on its body: disabled closes the fields and the submit", async () => {
|
|
181
|
+
const onSubmit = vi.fn();
|
|
182
|
+
const active = ref<"create" | "bind">("create");
|
|
183
|
+
const Host = defineComponent({
|
|
184
|
+
setup: () => () =>
|
|
185
|
+
h(HkLoginFlow, {
|
|
186
|
+
// Two credentials channels with DIFFERENT gates: erp's register
|
|
187
|
+
// body waits for its anti-abuse challenge, the bind body is
|
|
188
|
+
// submittable from the start. The guard is per channel, so it
|
|
189
|
+
// must travel with the swapped body rather than the flow.
|
|
190
|
+
channels: [
|
|
191
|
+
{ key: "create", mode: "credentials", disabled: true, submitLabel: "Create" },
|
|
192
|
+
{ key: "bind", mode: "credentials", submitLabel: "Continue" },
|
|
193
|
+
],
|
|
194
|
+
modelValue: active.value,
|
|
195
|
+
initialUsername: "demiurge",
|
|
196
|
+
onAccountSubmit: onSubmit,
|
|
197
|
+
}),
|
|
198
|
+
});
|
|
199
|
+
const c = mount(h(Host));
|
|
200
|
+
// Mid-dissolve BOTH bodies are mounted (the inner transition keeps
|
|
201
|
+
// the leaving item for its fade), so the probes read the settled
|
|
202
|
+
// item — the same scoping the stable-shell pins above use.
|
|
203
|
+
const settled = () =>
|
|
204
|
+
c.querySelector<HTMLElement>(
|
|
205
|
+
".hk-login-flow-body .hk-crossfade-item:not(.hk-crossfade-leave-active):not(.hk-crossfade-leave-to)",
|
|
206
|
+
)!;
|
|
207
|
+
const fieldOf = () =>
|
|
208
|
+
settled().querySelector<HTMLInputElement>('input[name="signin-username"]')!;
|
|
209
|
+
const submitOf = () =>
|
|
210
|
+
settled().querySelector<HTMLButtonElement>(".hk-btn-primary")!;
|
|
211
|
+
expect(fieldOf().disabled).toBe(true);
|
|
212
|
+
// MUT:channel-disabled-dropped (ignoring the channel's `disabled`
|
|
213
|
+
// leaves the gated body's submit enabled with a name in the field
|
|
214
|
+
// and this goes red).
|
|
215
|
+
expect(submitOf().disabled).toBe(true);
|
|
216
|
+
|
|
217
|
+
active.value = "bind";
|
|
218
|
+
for (let i = 0; i < 12; i++) await nextTick();
|
|
219
|
+
// The settled body is the bind one: its gate is open with the same
|
|
220
|
+
// typed name, which is what tells a per-channel guard apart from a
|
|
221
|
+
// flow-level one.
|
|
222
|
+
expect(submitOf().textContent).toContain("Continue");
|
|
223
|
+
expect(fieldOf().disabled).toBe(false);
|
|
224
|
+
expect(submitOf().disabled).toBe(false);
|
|
225
|
+
fieldOf().value = "langyo";
|
|
226
|
+
fieldOf().dispatchEvent(new Event("input"));
|
|
227
|
+
await nextTick();
|
|
228
|
+
submitOf().click();
|
|
229
|
+
await nextTick();
|
|
230
|
+
expect(onSubmit).toHaveBeenCalledWith("bind", "langyo", "");
|
|
231
|
+
});
|
|
179
232
|
});
|
|
180
233
|
|
|
181
234
|
describe("HkLoginFlow — sso channel", () => {
|
|
@@ -339,6 +392,65 @@ describe("HkLoginFlow — verify step", () => {
|
|
|
339
392
|
expect(c.querySelector(".hk-tabs")).toBeNull();
|
|
340
393
|
});
|
|
341
394
|
|
|
395
|
+
it("lists third-party sign-in rows on the verify step and forwards their selection", async () => {
|
|
396
|
+
const onVerify = vi.fn();
|
|
397
|
+
const onSelect = vi.fn();
|
|
398
|
+
const c = mount(
|
|
399
|
+
h(HkLoginFlow, {
|
|
400
|
+
channels: [cloudChannel],
|
|
401
|
+
modelValue: "cloud",
|
|
402
|
+
step: "verify",
|
|
403
|
+
verifyFactors: ["password"],
|
|
404
|
+
verifyAccountName: "langyo",
|
|
405
|
+
verifyMethods: [{ key: "github", label: "GitHub" }],
|
|
406
|
+
verifyMethodsDivider: "or continue with",
|
|
407
|
+
onVerify,
|
|
408
|
+
onVerifyMethodSelect: onSelect,
|
|
409
|
+
}),
|
|
410
|
+
);
|
|
411
|
+
const row = c.querySelector<HTMLButtonElement>('[data-key="github"]');
|
|
412
|
+
expect(row).not.toBeNull();
|
|
413
|
+
expect(c.querySelector(".hk-auth-channel-divider")?.textContent)
|
|
414
|
+
.toContain("or continue with");
|
|
415
|
+
// The rows live INSIDE the one card frame (the verify generation's
|
|
416
|
+
// body), not in a second card or below the panel.
|
|
417
|
+
expect(
|
|
418
|
+
c.querySelector(".s-auth-card")!.contains(c.querySelector(".hk-auth-channel-list")!),
|
|
419
|
+
).toBe(true);
|
|
420
|
+
row!.click();
|
|
421
|
+
await nextTick();
|
|
422
|
+
// MUT:flow-verify-method-unforwarded (dropping the `onMethod-select`
|
|
423
|
+
// forwarding leaves the host's handler uncalled and this goes red).
|
|
424
|
+
expect(onSelect).toHaveBeenCalledWith("github");
|
|
425
|
+
expect(onVerify).not.toHaveBeenCalled();
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
it("keeps the verify-step rows off the account step and off an empty list", () => {
|
|
429
|
+
const onAccount = mount(
|
|
430
|
+
h(HkLoginFlow, {
|
|
431
|
+
channels: [cloudChannel],
|
|
432
|
+
modelValue: "cloud",
|
|
433
|
+
verifyMethods: [{ key: "github", label: "GitHub" }],
|
|
434
|
+
}),
|
|
435
|
+
);
|
|
436
|
+
// MUT:flow-verify-methods-on-account (rendering the rows in the
|
|
437
|
+
// account generation as well puts a channel list on this probe and
|
|
438
|
+
// this goes red).
|
|
439
|
+
expect(onAccount.querySelector(".hk-auth-channel-list")).toBeNull();
|
|
440
|
+
const empty = mount(
|
|
441
|
+
h(HkLoginFlow, {
|
|
442
|
+
channels: [cloudChannel],
|
|
443
|
+
modelValue: "cloud",
|
|
444
|
+
step: "verify",
|
|
445
|
+
verifyFactors: ["totp"],
|
|
446
|
+
verifyMethods: [],
|
|
447
|
+
verifyMethodsDivider: "or",
|
|
448
|
+
}),
|
|
449
|
+
);
|
|
450
|
+
expect(empty.querySelector(".hk-auth-channel-list")).toBeNull();
|
|
451
|
+
expect(empty.querySelector(".hk-auth-channel-divider")).toBeNull();
|
|
452
|
+
});
|
|
453
|
+
|
|
342
454
|
it("morphs account → verify → back when the host flips the step prop reactively", async () => {
|
|
343
455
|
// The host mirrors every real consumer: reactive state read INSIDE
|
|
344
456
|
// the render function, so each change re-evaluates the props. (A
|
|
@@ -48,6 +48,13 @@ export interface HkLoginCredentialsChannel {
|
|
|
48
48
|
* opening card must not ask for it (2026-11 user direction). */
|
|
49
49
|
passwordField?: boolean;
|
|
50
50
|
submitLabel?: string;
|
|
51
|
+
/** Extra guard over the channel's WHOLE credentials body: the fields
|
|
52
|
+
* and the submit stay disabled while the host's own gate is closed
|
|
53
|
+
* (erp's register body: the anti-abuse challenge is still being
|
|
54
|
+
* solved). Default false — the built-in empty-field check is then the
|
|
55
|
+
* only guard. Per channel on purpose: one body may be gated while
|
|
56
|
+
* the other is always submittable. */
|
|
57
|
+
disabled?: boolean;
|
|
51
58
|
/** Alternative sign-in rows under the form (rendered only when
|
|
52
59
|
* non-empty; an empty list omits the whole methods block instead of
|
|
53
60
|
* padding a dead strip). */
|
|
@@ -108,6 +115,9 @@ export type HkLoginChannel = HkLoginCredentialsChannel | HkLoginSsoChannel;
|
|
|
108
115
|
* - `sso-click(channel)` — the primary sso row was picked.
|
|
109
116
|
* - `verify(kind, proof)` / `verify-resend` / `verify-back` — the MFA
|
|
110
117
|
* body's events, re-emitted one level up.
|
|
118
|
+
* - `verifyMethods` — alternative sign-in rows on the verify step (the
|
|
119
|
+
* third-party providers the account can still sign in through);
|
|
120
|
+
* `verify-method-select(key)` re-emits a picked row.
|
|
111
121
|
*
|
|
112
122
|
* Card grammar (2026-11-24 user direction, the reason this file looks
|
|
113
123
|
* the way it does): *"where the content can change inside the card, do
|
|
@@ -212,6 +222,16 @@ export const HkLoginFlow = defineComponent({
|
|
|
212
222
|
verifyLoading: { type: Boolean, default: false },
|
|
213
223
|
verifyResending: { type: Boolean, default: false },
|
|
214
224
|
passkeyRetryHint: { type: String, default: undefined },
|
|
225
|
+
/** Alternative sign-in rows on the verify step: the third-party
|
|
226
|
+
* providers the account can still sign in through (a linked OAuth
|
|
227
|
+
* identity). A row is not a factor — see HkMfaVerifyCard.methods.
|
|
228
|
+
* Rendered only when non-empty. */
|
|
229
|
+
verifyMethods: {
|
|
230
|
+
type: Array as PropType<readonly HkAuthChannelListEntry[]>,
|
|
231
|
+
default: () => [],
|
|
232
|
+
},
|
|
233
|
+
/** Divider text above the verify step's rows; consumer-localized. */
|
|
234
|
+
verifyMethodsDivider: { type: String, default: undefined },
|
|
215
235
|
},
|
|
216
236
|
emits: {
|
|
217
237
|
"update:modelValue": (_key: string) => true,
|
|
@@ -225,6 +245,9 @@ export const HkLoginFlow = defineComponent({
|
|
|
225
245
|
verify: (_kind: HkMfaFactor, _proof: string) => true,
|
|
226
246
|
"verify-resend": () => true,
|
|
227
247
|
"verify-back": () => true,
|
|
248
|
+
/** A third-party sign-in row was picked on the verify step — the
|
|
249
|
+
* provider's key, as `method-select` carries on the account step. */
|
|
250
|
+
"verify-method-select": (_key: string) => true,
|
|
228
251
|
},
|
|
229
252
|
setup(props, { emit, slots, expose }) {
|
|
230
253
|
const { t } = useI18n();
|
|
@@ -351,6 +374,7 @@ export const HkLoginFlow = defineComponent({
|
|
|
351
374
|
key={channel.key}
|
|
352
375
|
bare
|
|
353
376
|
loading={props.loading}
|
|
377
|
+
disabled={channel.disabled ?? false}
|
|
354
378
|
passwordField={channel.passwordField ?? false}
|
|
355
379
|
usernameType={channel.usernameType ?? "text"}
|
|
356
380
|
usernamePlaceholder={channel.usernamePlaceholder}
|
|
@@ -479,10 +503,13 @@ export const HkLoginFlow = defineComponent({
|
|
|
479
503
|
loading={props.verifyLoading}
|
|
480
504
|
resending={props.verifyResending}
|
|
481
505
|
passkeyRetryHint={props.passkeyRetryHint}
|
|
506
|
+
methods={props.verifyMethods}
|
|
507
|
+
methodsDivider={props.verifyMethodsDivider}
|
|
482
508
|
autofocus
|
|
483
509
|
onVerify={(kind: HkMfaFactor, proof: string) => emit("verify", kind, proof)}
|
|
484
510
|
onResend={() => emit("verify-resend")}
|
|
485
511
|
onBack={() => emit("verify-back")}
|
|
512
|
+
onMethod-select={(key: string) => emit("verify-method-select", key)}
|
|
486
513
|
/>
|
|
487
514
|
</div>
|
|
488
515
|
</div>
|
|
@@ -338,6 +338,135 @@ describe("HkMfaVerifyCard — autofocus arms the factor on stage", () => {
|
|
|
338
338
|
});
|
|
339
339
|
});
|
|
340
340
|
|
|
341
|
+
describe("HkMfaVerifyCard — alternative sign-in rows", () => {
|
|
342
|
+
// A host whose ladder also accepts a linked third-party identity lists
|
|
343
|
+
// the providers HERE (erp's "bind an existing account" verify step).
|
|
344
|
+
const rows = [
|
|
345
|
+
{ key: "github", label: "GitHub" },
|
|
346
|
+
{ key: "feishu", label: "Feishu" },
|
|
347
|
+
];
|
|
348
|
+
|
|
349
|
+
it("renders the rows under the proof and forwards a picked row", async () => {
|
|
350
|
+
const onVerify = vi.fn();
|
|
351
|
+
const onSelect = vi.fn();
|
|
352
|
+
const { container } = mount(() =>
|
|
353
|
+
h(HkMfaVerifyCard, {
|
|
354
|
+
factors: ["password"],
|
|
355
|
+
methods: rows,
|
|
356
|
+
methodsDivider: "or continue with",
|
|
357
|
+
onVerify,
|
|
358
|
+
onMethodSelect: onSelect,
|
|
359
|
+
}));
|
|
360
|
+
const github = container.querySelector<HTMLButtonElement>('[data-key="github"]');
|
|
361
|
+
expect(github).not.toBeNull();
|
|
362
|
+
expect(github!.getAttribute("aria-label")).toBe("GitHub");
|
|
363
|
+
expect(container.querySelector('[data-key="feishu"]')).not.toBeNull();
|
|
364
|
+
expect(container.querySelector(".hk-auth-channel-divider")?.textContent)
|
|
365
|
+
.toContain("or continue with");
|
|
366
|
+
// Lane order: proof → submit → rows → back. The back action is the
|
|
367
|
+
// last control of the step; the rows sit above it, inside the
|
|
368
|
+
// step-up's own column.
|
|
369
|
+
// MUT:verify-rows-after-back (moving the list below the back action
|
|
370
|
+
// puts the back button before the list and this goes red).
|
|
371
|
+
const list = container.querySelector(".hk-auth-channel-list")!;
|
|
372
|
+
const back = buttonText(container, "Back to sign in")!;
|
|
373
|
+
expect(
|
|
374
|
+
(list.compareDocumentPosition(back) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0,
|
|
375
|
+
"the back action follows the rows",
|
|
376
|
+
).toBe(true);
|
|
377
|
+
github!.click();
|
|
378
|
+
await flush();
|
|
379
|
+
// A row is not a factor: the pick reports the provider and leaves
|
|
380
|
+
// the verify lane alone.
|
|
381
|
+
// MUT:verify-rows-emit-verify (emitting `verify` from the row click
|
|
382
|
+
// calls onVerify here and this goes red).
|
|
383
|
+
expect(onSelect).toHaveBeenCalledWith("github");
|
|
384
|
+
expect(onSelect).toHaveBeenCalledTimes(1);
|
|
385
|
+
expect(onVerify).not.toHaveBeenCalled();
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it("omits the rows and the divider when no method is passed", () => {
|
|
389
|
+
// MUT:verify-rows-unconditional (dropping the length guard renders an
|
|
390
|
+
// empty list block under the proof — the divider-only list root
|
|
391
|
+
// appears and this goes red).
|
|
392
|
+
const { container } = mount(() => h(HkMfaVerifyCard, { factors: ["totp"] }));
|
|
393
|
+
expect(container.querySelector(".hk-auth-channel-list")).toBeNull();
|
|
394
|
+
expect(container.querySelector(".hk-auth-channel-divider")).toBeNull();
|
|
395
|
+
const empty = mount(() =>
|
|
396
|
+
h(HkMfaVerifyCard, { factors: ["totp"], methods: [], methodsDivider: "or" }));
|
|
397
|
+
expect(empty.container.querySelector(".hk-auth-channel-list")).toBeNull();
|
|
398
|
+
expect(empty.container.querySelector(".hk-auth-channel-divider")).toBeNull();
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it("keeps a provider row out of the factor picker", () => {
|
|
402
|
+
// The picker lists FACTORS only; a provider joins as a row below.
|
|
403
|
+
const { container } = mount(() =>
|
|
404
|
+
h(HkMfaVerifyCard, { factors: ["password", "totp"], methods: rows }));
|
|
405
|
+
expect(pickerButtons(container)).toHaveLength(2);
|
|
406
|
+
expect(
|
|
407
|
+
pickerButtons(container).some((b) => b.textContent?.includes("GitHub")),
|
|
408
|
+
).toBe(false);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it("closes every row while the card is busy", () => {
|
|
412
|
+
const busy = mount(() =>
|
|
413
|
+
h(HkMfaVerifyCard, { factors: ["password"], methods: rows, loading: true }));
|
|
414
|
+
const guarded = busy.container.querySelectorAll<HTMLButtonElement>(".hk-auth-channel-row");
|
|
415
|
+
expect(guarded).toHaveLength(2);
|
|
416
|
+
// MUT:verify-rows-live-while-busy (returning the rows untouched while
|
|
417
|
+
// `loading` leaves both enabled and this goes red).
|
|
418
|
+
expect(Array.from(guarded).every((row) => row.disabled)).toBe(true);
|
|
419
|
+
const disabled = mount(() =>
|
|
420
|
+
h(HkMfaVerifyCard, { factors: ["password"], methods: rows, disabled: true }));
|
|
421
|
+
expect(
|
|
422
|
+
Array.from(disabled.container.querySelectorAll<HTMLButtonElement>(".hk-auth-channel-row"))
|
|
423
|
+
.every((row) => row.disabled),
|
|
424
|
+
).toBe(true);
|
|
425
|
+
const idle = mount(() =>
|
|
426
|
+
h(HkMfaVerifyCard, { factors: ["password"], methods: rows }));
|
|
427
|
+
expect(
|
|
428
|
+
Array.from(idle.container.querySelectorAll<HTMLButtonElement>(".hk-auth-channel-row"))
|
|
429
|
+
.every((row) => !row.disabled),
|
|
430
|
+
).toBe(true);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
it("keeps a row the host closed ITSELF closed, busy or idle", () => {
|
|
434
|
+
// The prop doc promises "a row the host closed itself stays closed":
|
|
435
|
+
// the busy arm must ADD the flag, never overwrite the host's own. Both
|
|
436
|
+
// arms are probed because two different implementations each break
|
|
437
|
+
// exactly one of them (`disabled: loading || disabled` wipes the gate
|
|
438
|
+
// while idle, coercing idle rows to `false` wipes it too, and a
|
|
439
|
+
// clone that DROPS the field is the same defect).
|
|
440
|
+
// MUT:verify-rows-host-gateidle (coercing the idle arm to `disabled:
|
|
441
|
+
// false`) reds the first assertion; MUT:verify-rows-host-gatebusy
|
|
442
|
+
// (`disabled: props.loading || props.disabled` on every row) reds it
|
|
443
|
+
// as well once the card is idle.
|
|
444
|
+
const closed = [{ key: "github", label: "GitHub", disabled: true }, { key: "feishu", label: "Feishu" }];
|
|
445
|
+
const idle = mount(() =>
|
|
446
|
+
h(HkMfaVerifyCard, { factors: ["password"], methods: closed }));
|
|
447
|
+
const idleGithub = idle.container.querySelector<HTMLButtonElement>('[data-key="github"]')!;
|
|
448
|
+
const idleFeishu = idle.container.querySelector<HTMLButtonElement>('[data-key="feishu"]')!;
|
|
449
|
+
expect(idleGithub.disabled).toBe(true);
|
|
450
|
+
expect(idleFeishu.disabled).toBe(false);
|
|
451
|
+
|
|
452
|
+
const busy = mount(() =>
|
|
453
|
+
h(HkMfaVerifyCard, { factors: ["password"], methods: closed, loading: true }));
|
|
454
|
+
expect(
|
|
455
|
+
busy.container.querySelector<HTMLButtonElement>('[data-key="github"]')!.disabled,
|
|
456
|
+
).toBe(true);
|
|
457
|
+
expect(
|
|
458
|
+
busy.container.querySelector<HTMLButtonElement>('[data-key="feishu"]')!.disabled,
|
|
459
|
+
).toBe(true);
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
it("renders the rows in bare mode too (one body, two shells)", () => {
|
|
463
|
+
const { container } = mount(() =>
|
|
464
|
+
h(HkMfaVerifyCard, { bare: true, factors: ["password"], methods: rows }));
|
|
465
|
+
expect(container.querySelector('[data-key="github"]')).not.toBeNull();
|
|
466
|
+
expect(container.querySelector(".s-auth-card")).toBeNull();
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
|
|
341
470
|
describe("HkMfaVerifyCard — bare mode (host-owned card shell)", () => {
|
|
342
471
|
const flat = (key: string, fallback?: string) => fallback ?? key;
|
|
343
472
|
|
|
@@ -2,6 +2,7 @@ import { computed, defineComponent, nextTick, ref, watch, type PropType } from "
|
|
|
2
2
|
import { Asterisk, Fingerprint, KeyRound, MessageSquareText } from "lucide-vue-next";
|
|
3
3
|
|
|
4
4
|
import { useI18n } from "../i18n/context";
|
|
5
|
+
import HkAuthChannelList, { type HkAuthChannelListEntry } from "./HkAuthChannelList";
|
|
5
6
|
import { HkAuthCard } from "./HkAuthCard";
|
|
6
7
|
import HkAlert from "./HkAlert";
|
|
7
8
|
import HkAuthSubmitButton from "./HkAuthSubmitButton";
|
|
@@ -137,6 +138,14 @@ export function hkMfaVerifySubtitle(
|
|
|
137
138
|
* "one more verification" wording. The card re-selects and clears its
|
|
138
139
|
* fields whenever the announced set or the proven factor changes.
|
|
139
140
|
*
|
|
141
|
+
* Alternative sign-in rows (`methods`) are a SEPARATE lane from the
|
|
142
|
+
* factors: a host whose ladder also accepts a linked third-party
|
|
143
|
+
* identity for this account lists the providers under the proof field,
|
|
144
|
+
* and picking one emits `method-select(key)` instead of `verify` — the
|
|
145
|
+
* provider's own authorization round trip is the proof, and it happens
|
|
146
|
+
* on the host's side. The rows share the credentials card's channel
|
|
147
|
+
* list, so a provider reads the same on both steps.
|
|
148
|
+
*
|
|
140
149
|
* i18n: every visible string defaults to the `hikari::mfaVerify.*` locales
|
|
141
150
|
* (11 languages ship with the card); `title` / `subtitle` overrides win
|
|
142
151
|
* when a host needs its own wording. `{name}` / `{proven}` placeholders in
|
|
@@ -183,6 +192,23 @@ export const HkMfaVerifyCard = defineComponent({
|
|
|
183
192
|
* nudging toward the picker's other entries). Rendered only when
|
|
184
193
|
* set — the consumer owns the failure bookkeeping that decides it. */
|
|
185
194
|
passkeyRetryHint: { type: String, default: undefined },
|
|
195
|
+
/** Alternative sign-in rows UNDER the factor's proof field: the
|
|
196
|
+
* third-party providers this account can still sign in through (a
|
|
197
|
+
* linked OAuth identity — the erp "bind an existing account" ladder
|
|
198
|
+
* offers them beside password / totp). A row is NOT a factor: it
|
|
199
|
+
* never enters the picker and never emits `verify`; picking one
|
|
200
|
+
* hands the whole sign-in to the host (`method-select`), which
|
|
201
|
+
* usually leaves the page for the provider's authorization round
|
|
202
|
+
* trip. Rendered only when non-empty — the credentials card's
|
|
203
|
+
* `methods` rule: an empty list must not pad a dead strip under
|
|
204
|
+
* the submit. */
|
|
205
|
+
methods: {
|
|
206
|
+
type: Array as PropType<readonly HkAuthChannelListEntry[]>,
|
|
207
|
+
default: () => [],
|
|
208
|
+
},
|
|
209
|
+
/** Divider text above the rows; consumer-localized on purpose (the
|
|
210
|
+
* credentials channel's `methodsDivider` is the same contract). */
|
|
211
|
+
methodsDivider: { type: String, default: undefined },
|
|
186
212
|
/** Focus the factor ON STAGE when the card mounts (the verify step
|
|
187
213
|
* just opened) and whenever the selected factor changes: the proof
|
|
188
214
|
* field for `totp` / `sms` (HkOtpInput owns that one) / `password`,
|
|
@@ -215,6 +241,8 @@ export const HkMfaVerifyCard = defineComponent({
|
|
|
215
241
|
resend: () => true,
|
|
216
242
|
/** Abandon the step-up (back to the credentials card). */
|
|
217
243
|
back: () => true,
|
|
244
|
+
/** An alternative sign-in row was picked — the provider's key. */
|
|
245
|
+
"method-select": (_key: string) => true,
|
|
218
246
|
},
|
|
219
247
|
setup(props, { emit, slots, expose }) {
|
|
220
248
|
const { t } = useI18n();
|
|
@@ -346,6 +374,19 @@ export const HkMfaVerifyCard = defineComponent({
|
|
|
346
374
|
accountName: props.accountName,
|
|
347
375
|
}));
|
|
348
376
|
|
|
377
|
+
/** The alternative sign-in rows, in host order. While the card is
|
|
378
|
+
* busy (`loading` / `disabled`) every row is closed: the prop
|
|
379
|
+
* contract is "disables every control", and a provider round trip
|
|
380
|
+
* started mid-verify would strand the in-flight proof. A row the
|
|
381
|
+
* host closed itself stays closed. */
|
|
382
|
+
const methodsList = computed<HkAuthChannelListEntry[]>(() => {
|
|
383
|
+
// A fresh mutable list in both arms: the prop accepts a readonly
|
|
384
|
+
// array, the channel list's own prop is mutable.
|
|
385
|
+
return !props.loading && !props.disabled
|
|
386
|
+
? [...props.methods]
|
|
387
|
+
: props.methods.map((row) => ({ ...row, disabled: true }));
|
|
388
|
+
});
|
|
389
|
+
|
|
349
390
|
/** Glyph per factor for the icon-only picker — the labels ride the
|
|
350
391
|
* tooltip. The password entry wears the asterisk, the dot-matrix
|
|
351
392
|
* sign-in input's own shape. */
|
|
@@ -492,6 +533,13 @@ export const HkMfaVerifyCard = defineComponent({
|
|
|
492
533
|
: t("hikari::mfaVerify.resend", "Resend code")}
|
|
493
534
|
</HkButton>
|
|
494
535
|
)}
|
|
536
|
+
{methodsList.value.length > 0 && (
|
|
537
|
+
<HkAuthChannelList
|
|
538
|
+
divider={props.methodsDivider}
|
|
539
|
+
methods={methodsList.value}
|
|
540
|
+
onSelect={(key: string) => emit("method-select", key)}
|
|
541
|
+
/>
|
|
542
|
+
)}
|
|
495
543
|
<HkButton
|
|
496
544
|
variant="ghost"
|
|
497
545
|
size="md"
|