From d903015d4e5fc314659adfb70b7f3b637b896f60 Mon Sep 17 00:00:00 2001 From: dawn Date: Sat, 3 Oct 2026 19:57:21 +0300 Subject: [PATCH] web/organizations: show tranquil's reason for InvalidDelegation instead of calling it the cap Signed-off-by: dawn --- web/src/lib/api/delegation.test.ts | 14 +++++++++++++- web/src/lib/api/delegation.ts | 3 --- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/web/src/lib/api/delegation.test.ts b/web/src/lib/api/delegation.test.ts index 29614e0d..9e461a9c 100644 --- a/web/src/lib/api/delegation.test.ts +++ b/web/src/lib/api/delegation.test.ts @@ -54,7 +54,6 @@ describe("delegate provisioning", () => { }); it.each([ ["VerifiedEmailRequired", /Verify an email/], - ["InvalidDelegation", /reached the limit/], ["UpstreamUnavailable", /temporarily unavailable/] ])("explains %s", async (error, message) => { const { agent } = makeAgent(); @@ -81,6 +80,19 @@ describe("delegate provisioning", () => { }) ).rejects.toThrow(/Handle already taken/); }); + it("shows Tranquil's reason for InvalidDelegation, which is not only the delegate cap", async () => { + const { agent } = makeAgent(); + const message = "Invite-only registration requires an existing account on this PDS"; + await expect( + provisionDelegate(agent, "org.example", { + serviceUrl: "https://gate.example", + serviceDid: "did:web:tranquil.example", + fetch: vi.fn(async () => + Response.json({ error: "InvalidDelegation", message }, { status: 400 }) + ) + }) + ).rejects.toThrow(message); + }); it("does not request a token when the sidecar is not configured", async () => { const { agent, handle } = makeAgent(); await expect(provisionDelegate(agent, "org.example", { serviceUrl: "" })).rejects.toThrow( diff --git a/web/src/lib/api/delegation.ts b/web/src/lib/api/delegation.ts index a1893504..510b5431 100644 --- a/web/src/lib/api/delegation.ts +++ b/web/src/lib/api/delegation.ts @@ -64,9 +64,6 @@ export const provisionDelegate = async ( const messages: Record = { VerifiedEmailRequired: "Verify an email address in Settings → Emails before creating an organization.", - // Tranquil enforces the per-controller delegate cap and reports it as - // InvalidDelegation; the gate relays Tranquil's error code and message. - InvalidDelegation: "You have reached the limit on organizations you can create.", UpstreamUnavailable: "Organization creation is temporarily unavailable. Please try again later." }; -- 2.51.2