@celestia-island/hikari 0.55.515 → 0.55.516

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.
@@ -46,6 +46,22 @@ export interface HkLoginCredentialsChannel {
46
46
  * only offers Feishu): the card renders the standard channel list —
47
47
  * one full-width row naming the destination — and `sso-click` sends
48
48
  * the host off to build its OAuth URL. */
49
+ /** One provider row inside a multi-provider sso channel: the same row
50
+ * shape HkAuthChannelList renders, named by the provider's funnel key
51
+ * (the `methods[].id` the deployment descriptor publishes — "github",
52
+ * "qq", "feishu", …). */
53
+ export interface HkLoginSsoProvider {
54
+ key: string;
55
+ /** The row's visible name (e.g. 「GitHub 登录」). */
56
+ label: string;
57
+ /** Prebuilt icon vnode for the row's left mark. */
58
+ icon?: unknown;
59
+ disabled?: boolean;
60
+ /** Navigation target (the funnel's entry path); the host still
61
+ * receives `provider-select` first and the navigation is not
62
+ * prevented. Default undefined — the host navigates itself. */
63
+ href?: string;
64
+ }
49
65
  export interface HkLoginSsoChannel {
50
66
  key: string;
51
67
  mode: "sso";
@@ -64,6 +80,15 @@ export interface HkLoginSsoChannel {
64
80
  * prevented). Default undefined — the row is a button and the host
65
81
  * navigates on `sso-click`, as before. */
66
82
  href?: string;
83
+ /** Multi-provider body (2026-11-29 user direction): the segment group
84
+ * switches SOURCES ("Celestia 云 / 第三方认证") and this channel's
85
+ * body lists every third-party funnel as one full-width row each,
86
+ * in display order. The rows are the channel list form — the body
87
+ * IS the list, never rows stacked under a form. When present it
88
+ * replaces the single `icon`/`buttonLabel` row; `sso-click` stays
89
+ * for the single-provider shape, and picking a row emits
90
+ * `provider-select` with (channel key, provider key). */
91
+ providers?: HkLoginSsoProvider[];
67
92
  }
68
93
  export type HkLoginChannel = HkLoginCredentialsChannel | HkLoginSsoChannel;
69
94
  /**
@@ -270,6 +295,7 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
270
295
  "update:modelValue": (_key: string) => true;
271
296
  "account-submit": (_channel: string, _username: string, _password: string) => true;
272
297
  "sso-click": (_channel: string) => true;
298
+ "provider-select": (_channel: string, _provider: string) => true;
273
299
  verify: (_kind: HkMfaFactor, _proof: string) => true;
274
300
  "verify-resend": () => true;
275
301
  "verify-back": () => true;
@@ -379,6 +405,7 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
379
405
  onVerify?: ((_kind: "password" | "passkey" | "totp" | "sms", _proof: string) => any) | undefined;
380
406
  "onAccount-submit"?: ((_channel: string, _username: string, _password: string) => any) | undefined;
381
407
  "onSso-click"?: ((_channel: string) => any) | undefined;
408
+ "onProvider-select"?: ((_channel: string, _provider: string) => any) | undefined;
382
409
  "onVerify-resend"?: (() => any) | undefined;
383
410
  "onVerify-back"?: (() => any) | undefined;
384
411
  }>, {
@@ -498,6 +498,7 @@ export { HkLoginFlow as HkLoginFlow } from "./components/HkLoginFlow";
498
498
  export { type HkLoginChannel as HkLoginChannel } from "./components/HkLoginFlow";
499
499
  export { type HkLoginCredentialsChannel as HkLoginCredentialsChannel } from "./components/HkLoginFlow";
500
500
  export { type HkLoginSsoChannel as HkLoginSsoChannel } from "./components/HkLoginFlow";
501
+ export { type HkLoginSsoProvider as HkLoginSsoProvider } from "./components/HkLoginFlow";
501
502
  export { HkAuthSsoButton as HkAuthSsoButton } from "./components/HkAuthSsoButton";
502
503
  export { HkAuthChannelList as HkAuthChannelList } from "./components/HkAuthChannelList";
503
504
  export { type HkAuthChannelListEntry as HkAuthChannelListEntry } from "./components/HkAuthChannelList";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.515",
3
+ "version": "0.55.516",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -282,6 +282,92 @@ describe("HkLoginFlow — sso channel", () => {
282
282
  });
283
283
  });
284
284
 
285
+ describe("HkLoginFlow — multi-provider sso channel", () => {
286
+ const thirdParty: HkLoginChannel = {
287
+ key: "thirdparty",
288
+ mode: "sso",
289
+ icon: h("svg"),
290
+ providers: [
291
+ { key: "github", label: "GitHub 登录", icon: h("svg") },
292
+ { key: "qq", label: "QQ 登录", icon: h("svg") },
293
+ { key: "feishu", label: "飞书登录", icon: h("svg") },
294
+ ],
295
+ };
296
+
297
+ it("renders one full-width row per provider, in the given order", () => {
298
+ const c = mount(
299
+ h(HkLoginFlow, { channels: [cloudChannel, thirdParty], modelValue: "thirdparty" }),
300
+ );
301
+ const rows = within(c, "thirdparty").querySelectorAll(".hk-auth-channel-row");
302
+ expect(rows).toHaveLength(3);
303
+ expect(rows[0].getAttribute("data-key")).toBe("github");
304
+ expect(rows[1].getAttribute("data-key")).toBe("qq");
305
+ expect(rows[2].getAttribute("data-key")).toBe("feishu");
306
+ expect(rows[0].textContent).toContain("GitHub 登录");
307
+ });
308
+
309
+ it("emits provider-select with the channel and provider keys, not sso-click", async () => {
310
+ const onProviderSelect = vi.fn();
311
+ const onSsoClick = vi.fn();
312
+ const c = mount(
313
+ h(HkLoginFlow, {
314
+ channels: [thirdParty],
315
+ modelValue: "thirdparty",
316
+ onProviderSelect,
317
+ onSsoClick,
318
+ }),
319
+ );
320
+ const row = c.querySelector<HTMLButtonElement>(".hk-auth-channel-row")!;
321
+ expect(row.getAttribute("data-key")).toBe("github");
322
+ row.click();
323
+ await nextTick();
324
+ expect(onProviderSelect).toHaveBeenCalledWith("thirdparty", "github");
325
+ expect(onSsoClick).not.toHaveBeenCalled();
326
+ });
327
+
328
+ it("renders disabled rows inert and forwards per-row href links", () => {
329
+ const c = mount(
330
+ h(HkLoginFlow, {
331
+ channels: [{
332
+ key: "thirdparty",
333
+ mode: "sso",
334
+ icon: h("svg"),
335
+ providers: [
336
+ { key: "github", label: "GitHub 登录", href: "/auth/github/redirect" },
337
+ { key: "qq", label: "QQ 登录", disabled: true },
338
+ ],
339
+ }],
340
+ modelValue: "thirdparty",
341
+ }),
342
+ );
343
+ const link = c.querySelector<HTMLAnchorElement>(".hk-auth-channel-row")!;
344
+ expect(link.tagName).toBe("A");
345
+ expect(link.getAttribute("href")).toBe("/auth/github/redirect");
346
+ const disabled = c.querySelectorAll<HTMLButtonElement>(".hk-auth-channel-row")[1];
347
+ expect(disabled.tagName).toBe("BUTTON");
348
+ expect(disabled.disabled).toBe(true);
349
+ });
350
+
351
+ it("keeps the single-provider shape untouched when providers is absent or empty", async () => {
352
+ const onSsoClick = vi.fn();
353
+ for (const providers of [undefined, []]) {
354
+ const c = mount(
355
+ h(HkLoginFlow, {
356
+ channels: [{ ...orgChannel, providers }],
357
+ modelValue: "org",
358
+ onSsoClick,
359
+ }),
360
+ );
361
+ const row = c.querySelector<HTMLButtonElement>(".hk-auth-channel-row")!;
362
+ expect(row.getAttribute("data-key")).toBe("org");
363
+ row.click();
364
+ await nextTick();
365
+ expect(onSsoClick).toHaveBeenCalledWith("org");
366
+ }
367
+ expect(onSsoClick).toHaveBeenCalledTimes(2);
368
+ });
369
+ });
370
+
285
371
  describe("HkLoginFlow — verify step", () => {
286
372
  it("renders the step-up on an sso channel once the host announces factors (OAuth hand-off)", async () => {
287
373
  // The hand-off case: the OAuth callback returns with `mfa_pending` /
@@ -61,6 +61,23 @@ export interface HkLoginCredentialsChannel {
61
61
  * only offers Feishu): the card renders the standard channel list —
62
62
  * one full-width row naming the destination — and `sso-click` sends
63
63
  * the host off to build its OAuth URL. */
64
+ /** One provider row inside a multi-provider sso channel: the same row
65
+ * shape HkAuthChannelList renders, named by the provider's funnel key
66
+ * (the `methods[].id` the deployment descriptor publishes — "github",
67
+ * "qq", "feishu", …). */
68
+ export interface HkLoginSsoProvider {
69
+ key: string;
70
+ /** The row's visible name (e.g. 「GitHub 登录」). */
71
+ label: string;
72
+ /** Prebuilt icon vnode for the row's left mark. */
73
+ icon?: unknown;
74
+ disabled?: boolean;
75
+ /** Navigation target (the funnel's entry path); the host still
76
+ * receives `provider-select` first and the navigation is not
77
+ * prevented. Default undefined — the host navigates itself. */
78
+ href?: string;
79
+ }
80
+
64
81
  export interface HkLoginSsoChannel {
65
82
  key: string;
66
83
  mode: "sso";
@@ -79,6 +96,15 @@ export interface HkLoginSsoChannel {
79
96
  * prevented). Default undefined — the row is a button and the host
80
97
  * navigates on `sso-click`, as before. */
81
98
  href?: string;
99
+ /** Multi-provider body (2026-11-29 user direction): the segment group
100
+ * switches SOURCES ("Celestia 云 / 第三方认证") and this channel's
101
+ * body lists every third-party funnel as one full-width row each,
102
+ * in display order. The rows are the channel list form — the body
103
+ * IS the list, never rows stacked under a form. When present it
104
+ * replaces the single `icon`/`buttonLabel` row; `sso-click` stays
105
+ * for the single-provider shape, and picking a row emits
106
+ * `provider-select` with (channel key, provider key). */
107
+ providers?: HkLoginSsoProvider[];
82
108
  }
83
109
 
84
110
  export type HkLoginChannel = HkLoginCredentialsChannel | HkLoginSsoChannel;
@@ -246,6 +272,11 @@ export const HkLoginFlow = defineComponent({
246
272
  "update:modelValue": (_key: string) => true,
247
273
  "account-submit": (_channel: string, _username: string, _password: string) => true,
248
274
  "sso-click": (_channel: string) => true,
275
+ // A multi-provider sso channel's row was picked: (channel key,
276
+ // provider key) — the provider key is the funnel id the host's
277
+ // descriptor publishes ("github", "qq", "feishu", …), so the host
278
+ // routes to that funnel's own entry path.
279
+ "provider-select": (_channel: string, _provider: string) => true,
249
280
  // `verify` carries HkMfaFactor (not a bare string): consumers bind
250
281
  // factor-typed handlers (`onVerify={(kind: MfaFactor, …)}`), and a
251
282
  // wider `string` param fails TS2322 under strictFunctionTypes —
@@ -402,6 +433,24 @@ export const HkLoginFlow = defineComponent({
402
433
  }
403
434
 
404
435
  function renderSsoBody(channel: HkLoginSsoChannel) {
436
+ const providers = channel.providers ?? [];
437
+ if (providers.length > 0) {
438
+ return (
439
+ <div key={channel.key} class="hk-login-flow-sso">
440
+ <HkAuthChannelList
441
+ methods={providers.map((provider) => ({
442
+ key: provider.key,
443
+ label: provider.label,
444
+ icon: provider.icon,
445
+ disabled: provider.disabled,
446
+ href: provider.href,
447
+ }))}
448
+ onSelect={(providerKey: string) =>
449
+ emit("provider-select", channel.key, providerKey)}
450
+ />
451
+ </div>
452
+ );
453
+ }
405
454
  return (
406
455
  <div key={channel.key} class="hk-login-flow-sso">
407
456
  <HkAuthChannelList
@@ -1,7 +1,7 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta name="hk-error-landing" content="v1 0.55.515 <dev>">
4
+ <meta name="hk-error-landing" content="v1 0.55.516 <dev>">
5
5
  <meta charset="utf-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
  <meta name="robots" content="noindex" />
package/src/index.ts CHANGED
@@ -1148,6 +1148,7 @@ export { HkLoginFlow as HkLoginFlow } from "./components/HkLoginFlow";
1148
1148
  export { type HkLoginChannel as HkLoginChannel } from "./components/HkLoginFlow";
1149
1149
  export { type HkLoginCredentialsChannel as HkLoginCredentialsChannel } from "./components/HkLoginFlow";
1150
1150
  export { type HkLoginSsoChannel as HkLoginSsoChannel } from "./components/HkLoginFlow";
1151
+ export { type HkLoginSsoProvider as HkLoginSsoProvider } from "./components/HkLoginFlow";
1151
1152
  export { HkAuthSsoButton as HkAuthSsoButton } from "./components/HkAuthSsoButton";
1152
1153
  export { HkAuthChannelList as HkAuthChannelList } from "./components/HkAuthChannelList";
1153
1154
  export { type HkAuthChannelListEntry as HkAuthChannelListEntry } from "./components/HkAuthChannelList";