Skip to content

Commit ef42656

Browse files
loganjLarry
andcommitted
fix(desktop): align hosted create/onboarding identity rows with bound key
The create-flow and onboarding siblings of the hosted-communities settings card keyed their mismatch gates and recovery actions on the bound pubkey_hex yet rendered their identity rows from the server-sent npub, so a response whose npub spelled a different (individually valid) key displayed one identity while the gate and every recovery action acted on another. Derive both rows from the authoritative fields via canonicalNpub — the account row from the bound pubkey_hex, the device row from the local key — and render the neutral label when a hex is unusable, never the unverified npub spelling or raw hex (follow-up on #7489). Browser specs drive the real surfaces end to end: the create flow asserts the bound key's npub and the neutral-label fallback for an unusable hex, the settings card asserts mismatch, connected, consistent, and unusable states through its real providers (carrying over the coverage of the deleted card-mounted renderer harness), and the first-community owner onboarding test asserts the authoritative rows under a contradictory hosted npub. Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson <[email protected]>
1 parent ec7d7d3 commit ef42656

6 files changed

Lines changed: 211 additions & 342 deletions

‎desktop/src/features/communities/ui/HostedCommunityCreateFlow.tsx‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
} from "@/features/channels/ui/channelFormStyles";
2828
import { useIdentityQuery } from "@/shared/api/hooks";
2929
import { cn } from "@/shared/lib/cn";
30-
import { safeNpub } from "@/shared/lib/nostrUtils";
30+
import { canonicalNpub, UNAVAILABLE_KEY_LABEL } from "@/shared/lib/pubkey";
3131
import { Button } from "@/shared/ui/button";
3232
import { Input } from "@/shared/ui/input";
3333

@@ -154,7 +154,14 @@ export function HostedCommunityCreateFlow({
154154
localPubkey &&
155155
boundPubkey.toLowerCase() !== localPubkey.toLowerCase(),
156156
);
157-
const localNpub = localPubkey ? safeNpub(localPubkey) : null;
157+
// Identity rows display npubs derived from the same key the mismatch gate
158+
// and recovery actions act on: the account row from the authoritative
159+
// bound `pubkey_hex` — the server-sent `npub` is an independent field that
160+
// nothing on this path proves encodes the same key — and the device row
161+
// from the local key. An unencodable or non-identity-length key renders the
162+
// neutral label instead of leaking raw hex or the unverified npub.
163+
const localNpub = localPubkey ? canonicalNpub(localPubkey) : null;
164+
const boundNpub = boundPubkey ? canonicalNpub(boundPubkey) : null;
158165

159166
const switchToDeviceIdentity = () =>
160167
run("Switching identity…", async () => {
@@ -343,9 +350,11 @@ export function HostedCommunityCreateFlow({
343350
this device, or sign in with another account.
344351
</p>
345352
<div className="rounded-xl bg-muted/40 px-4 py-3 font-mono text-xs text-muted-foreground">
346-
<p className="break-all">Account: {identity.npub ?? boundPubkey}</p>
353+
<p className="break-all">
354+
Account: {boundNpub ?? UNAVAILABLE_KEY_LABEL}
355+
</p>
347356
<p className="mt-1 break-all">
348-
This device: {localNpub ?? localPubkey}
357+
This device: {localNpub ?? UNAVAILABLE_KEY_LABEL}
349358
</p>
350359
</div>
351360
{errorBox}

‎desktop/src/features/communities/ui/HostedCommunityOnboarding.tsx‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from "@/features/communities/hostedCommunityApi";
2424
import { useCommunityOnboarding } from "@/features/onboarding/communityOnboarding";
2525
import { useIdentityQuery } from "@/shared/api/hooks";
26-
import { safeNpub } from "@/shared/lib/nostrUtils";
26+
import { canonicalNpub, UNAVAILABLE_KEY_LABEL } from "@/shared/lib/pubkey";
2727
import { Button } from "@/shared/ui/button";
2828
import { Card } from "@/shared/ui/card";
2929
import { Input } from "@/shared/ui/input";
@@ -202,7 +202,14 @@ export function HostedCommunityOnboarding({
202202
localPubkey &&
203203
boundPubkey.toLowerCase() !== localPubkey.toLowerCase(),
204204
);
205-
const localNpub = localPubkey ? safeNpub(localPubkey) : null;
205+
// Identity rows display npubs derived from the same key the mismatch gate
206+
// and recovery actions act on: the account row from the authoritative
207+
// bound `pubkey_hex` — the server-sent `npub` is an independent field that
208+
// nothing on this path proves encodes the same key — and the device row
209+
// from the local key. An unencodable or non-identity-length key renders the
210+
// neutral label instead of leaking raw hex or the unverified npub.
211+
const localNpub = localPubkey ? canonicalNpub(localPubkey) : null;
212+
const boundNpub = boundPubkey ? canonicalNpub(boundPubkey) : null;
206213

207214
const switchToDeviceIdentity = () =>
208215
run("Switching identity…", async () => {
@@ -543,9 +550,9 @@ export function HostedCommunityOnboarding({
543550
this device, or sign out to use a different email.
544551
</DialogDescription>
545552
<p className="mt-4 w-full break-all rounded-xl bg-[rgb(var(--buzz-hosted-community-identity-bg)/0.5)] px-4 py-3 text-left font-mono text-xs text-foreground">
546-
Account: {identity.npub ?? boundPubkey}
553+
Account: {boundNpub ?? UNAVAILABLE_KEY_LABEL}
547554
<br />
548-
This device: {localNpub ?? localPubkey}
555+
This device: {localNpub ?? UNAVAILABLE_KEY_LABEL}
549556
</p>
550557
{errorBox ? <div className="mt-5 w-full">{errorBox}</div> : null}
551558
<div className="mt-6 flex flex-col items-stretch gap-2">

0 commit comments

Comments
 (0)