mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28d53e0100 | ||
|
|
dbb90df240 |
No files matched your search
@@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [9.16.1] - 2026-09-13
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Deploying to a name you already own works again — names you took back in the migration were reported as taken by somebody else, and the Deploy button refused to publish to your own site
|
||||||
|
|
||||||
## [9.16.0] - 2026-09-13
|
## [9.16.0] - 2026-09-13
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"description": "Build custom apps with AI assistance using Shakespeare, an open-source development environment",
|
"description": "Build custom apps with AI assistance using Shakespeare, an open-source development environment",
|
||||||
"homepage": "https://shakespeare.diy",
|
"homepage": "https://shakespeare.diy",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"version": "9.16.0",
|
"version": "9.16.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "shakespeare.diy",
|
"name": "shakespeare.diy",
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [9.16.1] - 2026-09-13
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Deploying to a name you already own works again — names you took back in the migration were reported as taken by somebody else, and the Deploy button refused to publish to your own site
|
||||||
|
|
||||||
## [9.16.0] - 2026-09-13
|
## [9.16.0] - 2026-09-13
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { AlertCircle, Check, Loader2 } from 'lucide-react';
|
|||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
|
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||||
import { checkNameAvailable, type NameAvailability } from '@/lib/deploy/NpanelAdapter';
|
import { checkNameAvailable, type NameAvailability } from '@/lib/deploy/NpanelAdapter';
|
||||||
|
|
||||||
/** How long typing has to stop before the gateway is asked about a name. */
|
/** How long typing has to stop before the gateway is asked about a name. */
|
||||||
@@ -34,6 +35,11 @@ type NameState =
|
|||||||
| { kind: 'unavailable'; message: string };
|
| { kind: 'unavailable'; message: string };
|
||||||
|
|
||||||
function describe(availability: NameAvailability, domain: string): NameState {
|
function describe(availability: NameAvailability, domain: string): NameState {
|
||||||
|
// A name the gateway recognises as this user's own. It is spoken for, and
|
||||||
|
// they are who it is spoken for by — deploying updates the site already
|
||||||
|
// there rather than taking anything.
|
||||||
|
if (availability.reason === 'mine') return { kind: 'mine' };
|
||||||
|
|
||||||
if (availability.available) return { kind: 'free' };
|
if (availability.available) return { kind: 'free' };
|
||||||
|
|
||||||
if (availability.reason === 'taken') {
|
if (availability.reason === 'taken') {
|
||||||
@@ -56,6 +62,7 @@ export function NpanelDeployForm({
|
|||||||
onSiteDescriptionChange,
|
onSiteDescriptionChange,
|
||||||
onValidationChange,
|
onValidationChange,
|
||||||
}: NpanelDeployFormProps) {
|
}: NpanelDeployFormProps) {
|
||||||
|
const { user } = useCurrentUser();
|
||||||
const [subdomain, setSubdomain] = useState(savedSubdomain || projectId);
|
const [subdomain, setSubdomain] = useState(savedSubdomain || projectId);
|
||||||
const [siteTitle, setSiteTitle] = useState(savedSiteTitle ?? projectName);
|
const [siteTitle, setSiteTitle] = useState(savedSiteTitle ?? projectName);
|
||||||
const [siteDescription, setSiteDescription] = useState(savedSiteDescription ?? '');
|
const [siteDescription, setSiteDescription] = useState(savedSiteDescription ?? '');
|
||||||
@@ -87,12 +94,12 @@ export function NpanelDeployForm({
|
|||||||
|
|
||||||
// The name this project already deployed to is not "taken" — it is theirs,
|
// The name this project already deployed to is not "taken" — it is theirs,
|
||||||
// and asking the gateway would truthfully say taken and alarm them about
|
// and asking the gateway would truthfully say taken and alarm them about
|
||||||
// their own site.
|
// their own site. Compared trimmed, since that is what gets deployed: a
|
||||||
const isOwnName = Boolean(savedSubdomain) && subdomain === savedSubdomain;
|
// trailing space is not a different name.
|
||||||
|
const trimmed = subdomain.trim();
|
||||||
|
const isOwnName = Boolean(savedSubdomain) && trimmed === savedSubdomain;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const trimmed = subdomain.trim();
|
|
||||||
|
|
||||||
if (!trimmed) {
|
if (!trimmed) {
|
||||||
setNameState({ kind: 'empty' });
|
setNameState({ kind: 'empty' });
|
||||||
return;
|
return;
|
||||||
@@ -106,10 +113,14 @@ export function NpanelDeployForm({
|
|||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timer = setTimeout(async () => {
|
const timer = setTimeout(async () => {
|
||||||
|
// Signed, where there is someone to sign: a name this user owns but this
|
||||||
|
// project has never deployed to — one they took back through the
|
||||||
|
// migration — is otherwise indistinguishable from a stranger's.
|
||||||
const availability = await checkNameAvailable(
|
const availability = await checkNameAvailable(
|
||||||
dashboardHost,
|
dashboardHost,
|
||||||
`${trimmed}.${domain}`,
|
`${trimmed}.${domain}`,
|
||||||
controller.signal,
|
controller.signal,
|
||||||
|
user?.signer,
|
||||||
);
|
);
|
||||||
if (!controller.signal.aborted) setNameState(describe(availability, domain));
|
if (!controller.signal.aborted) setNameState(describe(availability, domain));
|
||||||
}, AVAILABILITY_DEBOUNCE_MS);
|
}, AVAILABILITY_DEBOUNCE_MS);
|
||||||
@@ -118,7 +129,7 @@ export function NpanelDeployForm({
|
|||||||
controller.abort();
|
controller.abort();
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
};
|
};
|
||||||
}, [subdomain, isOwnName, dashboardHost, domain]);
|
}, [trimmed, isOwnName, dashboardHost, domain, user?.signer]);
|
||||||
|
|
||||||
// A name still being checked stays deployable: the gateway decides for real
|
// A name still being checked stays deployable: the gateway decides for real
|
||||||
// when the deploy runs, and blocking the button on an in-flight request would
|
// when the deploy runs, and blocking the button on an in-flight request would
|
||||||
|
|||||||
@@ -222,4 +222,52 @@ describe('checkNameAvailable', () => {
|
|||||||
available: true,
|
available: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('asks again as the signer when a name comes back taken', async () => {
|
||||||
|
// "Taken" and "taken by you" are the same word to a stranger and opposite
|
||||||
|
// answers to the person about to deploy.
|
||||||
|
fetchMock
|
||||||
|
.mockResolvedValueOnce(
|
||||||
|
new Response(JSON.stringify({ hostname: `x.${DOMAIN}`, available: false, reason: 'taken' })),
|
||||||
|
)
|
||||||
|
.mockResolvedValueOnce(
|
||||||
|
new Response(JSON.stringify({ hostname: `x.${DOMAIN}`, available: true, reason: 'mine' })),
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
checkNameAvailable(DASHBOARD_HOST, `x.${DOMAIN}`, undefined, signer),
|
||||||
|
).resolves.toMatchObject({ available: true, reason: 'mine' });
|
||||||
|
|
||||||
|
expect(fetchMock).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
|
// The first ask carries nothing; only the second spends a signature.
|
||||||
|
const [, anonymous] = fetchMock.mock.calls[0];
|
||||||
|
expect((anonymous as RequestInit | undefined)?.headers).toBeUndefined();
|
||||||
|
|
||||||
|
const signed = fetchMock.mock.calls[1][0] as Request;
|
||||||
|
expect(signed.headers.get('Authorization')).toMatch(/^Nostr /);
|
||||||
|
expect(signed.url).toBe(`https://${DASHBOARD_HOST}/api/hosts/x.${DOMAIN}/available`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('spends no signature on a name that is free', async () => {
|
||||||
|
// Picking a new name is the common case, and a remote signer on the other
|
||||||
|
// end of every keystroke is not something to spend it on.
|
||||||
|
fetchMock.mockResolvedValue(new Response(JSON.stringify({ hostname: 'x', available: true })));
|
||||||
|
|
||||||
|
await checkNameAvailable(DASHBOARD_HOST, `x.${DOMAIN}`, undefined, signer);
|
||||||
|
|
||||||
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps the public answer when the gateway is too old to know better', async () => {
|
||||||
|
fetchMock
|
||||||
|
.mockResolvedValueOnce(
|
||||||
|
new Response(JSON.stringify({ hostname: `x.${DOMAIN}`, available: false, reason: 'taken' })),
|
||||||
|
)
|
||||||
|
.mockResolvedValueOnce(new Response('nope', { status: 404 }));
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
checkNameAvailable(DASHBOARD_HOST, `x.${DOMAIN}`, undefined, signer),
|
||||||
|
).resolves.toMatchObject({ available: false, reason: 'taken' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -10,7 +10,13 @@ const NAMED_SITE_KIND = 35128;
|
|||||||
export interface NameAvailability {
|
export interface NameAvailability {
|
||||||
hostname: string;
|
hostname: string;
|
||||||
available: boolean;
|
available: boolean;
|
||||||
reason?: 'taken' | 'invalid';
|
/**
|
||||||
|
* Why it is not free, or — with `available` — that it is not free of somebody
|
||||||
|
* else. `mine` comes only from a signed request, and only from a gateway new
|
||||||
|
* enough to answer one; an older one says `taken` and is not wrong, just less
|
||||||
|
* use to the person who owns the name.
|
||||||
|
*/
|
||||||
|
reason?: 'taken' | 'invalid' | 'mine';
|
||||||
/** Present when `reason` is `invalid`; written to be shown to whoever typed it. */
|
/** Present when `reason` is `invalid`; written to be shown to whoever typed it. */
|
||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
@@ -18,9 +24,15 @@ export interface NameAvailability {
|
|||||||
/**
|
/**
|
||||||
* Ask whether a name can still be claimed.
|
* Ask whether a name can still be claimed.
|
||||||
*
|
*
|
||||||
* Unauthenticated, and deliberately so: someone choosing a name has not decided
|
* Asked anonymously first, and deliberately so: someone choosing a name has not
|
||||||
* to make an account yet, and making them prove who they are to find out their
|
* decided to make an account yet, and making them prove who they are to find out
|
||||||
* first choice is taken would be a strange order to do things in.
|
* their first choice is taken would be a strange order to do things in.
|
||||||
|
*
|
||||||
|
* A name that comes back taken is then asked about again, signed, because
|
||||||
|
* "taken" and "taken by you" are the same answer to a stranger and opposite
|
||||||
|
* answers to the person about to deploy. Only on that branch: a free name is the
|
||||||
|
* common case while somebody is picking one, and signing every keystroke would
|
||||||
|
* put a remote signer on the other end of the typing.
|
||||||
*
|
*
|
||||||
* A network failure answers `available: true` rather than blocking the person.
|
* A network failure answers `available: true` rather than blocking the person.
|
||||||
* Being wrong that way costs a clear error at deploy time; being wrong the other
|
* Being wrong that way costs a clear error at deploy time; being wrong the other
|
||||||
@@ -30,13 +42,23 @@ export async function checkNameAvailable(
|
|||||||
dashboardHost: string,
|
dashboardHost: string,
|
||||||
hostname: string,
|
hostname: string,
|
||||||
signal?: AbortSignal,
|
signal?: AbortSignal,
|
||||||
|
signer?: NostrSigner,
|
||||||
): Promise<NameAvailability> {
|
): Promise<NameAvailability> {
|
||||||
const url = `https://${dashboardHost}/api/hosts/${encodeURIComponent(hostname)}/available`;
|
const path = `/api/hosts/${encodeURIComponent(hostname)}/available`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, { signal: signal ?? AbortSignal.timeout(NPANEL_TIMEOUT_MS) });
|
const response = await fetch(`https://${dashboardHost}${path}`, {
|
||||||
|
signal: signal ?? AbortSignal.timeout(NPANEL_TIMEOUT_MS),
|
||||||
|
});
|
||||||
if (!response.ok) return { hostname, available: true };
|
if (!response.ok) return { hostname, available: true };
|
||||||
return (await response.json()) as NameAvailability;
|
|
||||||
|
const availability = (await response.json()) as NameAvailability;
|
||||||
|
if (availability.available || availability.reason !== 'taken' || !signer) return availability;
|
||||||
|
|
||||||
|
const asOwner = await npanelRequest(dashboardHost, signer, 'GET', path, undefined, signal);
|
||||||
|
if (!asOwner.ok) return availability;
|
||||||
|
|
||||||
|
return (await asOwner.json()) as NameAvailability;
|
||||||
} catch {
|
} catch {
|
||||||
return { hostname, available: true };
|
return { hostname, available: true };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user