Let people take back the sites they had before the gateway

The domains Shakespeare Deploy published to are now served by a gateway that
took them over, and the sites already under those names had to keep working, so
they were republished under an archive key rather than left to break. That key
is not theirs. This is how it stops speaking for them: the gateway holds a
record of who each name is waiting for, they publish their own copy of the site,
and the name is repointed at it.

All of it at once, because the person with one name to recover is not the person
this is for. Doing it a site at a time through the deploy button would mean
re-deploying a hundred projects, most of which are no longer checked out
anywhere, to recover sites whose files the gateway already has.

The list is only reached by asking, never on page load: finding out what is
waiting costs a signature, and a signing prompt nobody asked for is worse than a
button that sometimes opens an empty list.

A name whose site was always published under its owner's key needs nothing
republished — the record is the whole migration. The rest need the archived
manifest signed again, which reproduces the site exactly, since a manifest is
its tags and the blobs are addressed by hash and already sit where the server
tags say. Publishing happens before claiming, so the name never points at an
event the gateway has not fetched.

What a name must never do is come back at the cost of a live one. Kind 35128 is
addressable, so republishing an archived snapshot at a `d` tag someone already
publishes under would replace the current site with an old copy of itself —
which is not hypothetical: two of the first hundred names looked at were exactly
that. Those are claimed straight to the site that already exists, so both names
end up serving it. Working that out needs relays to answer, so silence from them
is treated as silence and not as "publishes nothing": a user whose own sites the
gateway is already serving must see at least those come back, or nothing is
planned at all.

Also fixes ProviderConfigDialog, which had grown a relay list and a server list
and no height limit, and was pushing its own Save button off the bottom of the
screen with no way to scroll to it.
This commit is contained in:
Alex Gleason committed 2026-09-13 15:05:37 -05:00
1 parent fc26a8b27b
commit cb5561ba69
8 files changed
+715 -40

No files matched your search

+6 -35
View File
@@ -1,15 +1,11 @@
import { NIP98 } from '@nostrify/nostrify';
import { N64 } from '@nostrify/nostrify/utils';
import type { NostrSigner } from '@nostrify/nostrify';
import type { DeployAdapter, DeployOptions, DeployResult, NpanelDeployConfig } from './types';
import { NsiteAdapter } from './NsiteAdapter';
import { NPANEL_TIMEOUT_MS, npanelError, npanelRequest } from './npanelApi';
/** nsite named-site kind. An npanel host always points at one of these. */
const NAMED_SITE_KIND = 35128;
/** Timeout for a single API call (ms). */
const FETCH_TIMEOUT_MS = 15_000;
/** What `GET /api/hosts/:hostname/available` answers. */
export interface NameAvailability {
hostname: string;
@@ -38,7 +34,7 @@ export async function checkNameAvailable(
const url = `https://${dashboardHost}/api/hosts/${encodeURIComponent(hostname)}/available`;
try {
const response = await fetch(url, { signal: signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS) });
const response = await fetch(url, { signal: signal ?? AbortSignal.timeout(NPANEL_TIMEOUT_MS) });
if (!response.ok) return { hostname, available: true };
return (await response.json()) as NameAvailability;
} catch {
@@ -146,37 +142,12 @@ export class NpanelAdapter implements DeployAdapter {
}
/** A NIP-98 request to the gateway's API. */
private async request(method: string, path: string, body?: unknown): Promise<Response> {
const url = `https://${this.dashboardHost}${path}`;
let request = new Request(url, {
method,
...(body === undefined
? {}
: { body: JSON.stringify(body), headers: { 'Content-Type': 'application/json' } }),
});
// Signed against the URL being requested, so the token authorizes this call
// and no other. No CORS proxy: npanel answers browsers directly, and a proxy
// would rewrite the URL out from under the signature.
const template = await NIP98.template(request);
const event = await this.signer.signEvent(template);
const headers = new Headers(request.headers);
headers.set('Authorization', `Nostr ${N64.encodeEvent(event)}`);
request = new Request(request, { headers, signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
return await fetch(request);
private request(method: string, path: string, body?: unknown): Promise<Response> {
return npanelRequest(this.dashboardHost, this.signer, method, path, body);
}
/** The gateway's own sentence about a failure, which is written to be read. */
private async error(response: Response, fallback: string): Promise<Error> {
const body = await response.json().catch(() => null) as { error?: string } | null;
if (response.status === 403 && !body?.error) {
return new Error(`${fallback}: this gateway is not accepting new sites right now.`);
}
return new Error(body?.error ?? `${fallback} (HTTP ${response.status}).`);
private error(response: Response, fallback: string): Promise<Error> {
return npanelError(response, fallback);
}
}