Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place

fix self

Changed files
+35 -8
hosting-service
src
src
lib
routes
+1 -1
hosting-service/src/lib/db.ts
··· 17 17 id: string; 18 18 domain: string; 19 19 did: string; 20 - rkey: string; 20 + rkey: string | null; 21 21 verified: boolean; 22 22 } 23 23
+18 -3
hosting-service/src/server.ts
··· 296 296 return 'Custom domain not found or not verified'; 297 297 } 298 298 299 - const rkey = customDomain.rkey || 'self'; 299 + if (!customDomain.rkey) { 300 + set.status = 404; 301 + return 'Domain not mapped to a site'; 302 + } 303 + 304 + const rkey = customDomain.rkey; 300 305 if (!isValidRkey(rkey)) { 301 306 set.status = 500; 302 307 return 'Invalid site configuration'; ··· 321 326 return 'Subdomain not registered'; 322 327 } 323 328 324 - const rkey = domainInfo.rkey || 'self'; 329 + if (!domainInfo.rkey) { 330 + set.status = 404; 331 + return 'Domain not mapped to a site'; 332 + } 333 + 334 + const rkey = domainInfo.rkey; 325 335 if (!isValidRkey(rkey)) { 326 336 set.status = 500; 327 337 return 'Invalid site configuration'; ··· 343 353 return 'Custom domain not found or not verified'; 344 354 } 345 355 346 - const rkey = customDomain.rkey || 'self'; 356 + if (!customDomain.rkey) { 357 + set.status = 404; 358 + return 'Domain not mapped to a site'; 359 + } 360 + 361 + const rkey = customDomain.rkey; 347 362 if (!isValidRkey(rkey)) { 348 363 set.status = 500; 349 364 return 'Invalid site configuration';
+15 -3
src/lib/db.ts
··· 77 77 id TEXT PRIMARY KEY, 78 78 domain TEXT UNIQUE NOT NULL, 79 79 did TEXT NOT NULL, 80 - rkey TEXT NOT NULL DEFAULT 'self', 80 + rkey TEXT, 81 81 verified BOOLEAN DEFAULT false, 82 82 last_verified_at BIGINT, 83 83 created_at BIGINT DEFAULT EXTRACT(EPOCH FROM NOW()) 84 84 ) 85 85 `; 86 + 87 + // Migrate existing tables to make rkey nullable and remove default 88 + try { 89 + await db`ALTER TABLE custom_domains ALTER COLUMN rkey DROP NOT NULL`; 90 + } catch (err) { 91 + // Column might already be nullable, ignore 92 + } 93 + try { 94 + await db`ALTER TABLE custom_domains ALTER COLUMN rkey DROP DEFAULT`; 95 + } catch (err) { 96 + // Default might already be removed, ignore 97 + } 86 98 87 99 // Sites table - cache of place.wisp.fs records from PDS 88 100 await db` ··· 462 474 return rows[0] ?? null; 463 475 }; 464 476 465 - export const claimCustomDomain = async (did: string, domain: string, hash: string, rkey: string = 'self') => { 477 + export const claimCustomDomain = async (did: string, domain: string, hash: string, rkey: string | null = null) => { 466 478 const domainLower = domain.toLowerCase(); 467 479 try { 468 480 await db` ··· 476 488 } 477 489 }; 478 490 479 - export const updateCustomDomainRkey = async (id: string, rkey: string) => { 491 + export const updateCustomDomainRkey = async (id: string, rkey: string | null) => { 480 492 const rows = await db` 481 493 UPDATE custom_domains 482 494 SET rkey = ${rkey}
+1 -1
src/routes/domain.ts
··· 336 336 } 337 337 338 338 // Update custom domain to point to this site 339 - await updateCustomDomainRkey(id, siteRkey || 'self'); 339 + await updateCustomDomainRkey(id, siteRkey); 340 340 341 341 return { success: true }; 342 342 } catch (err) {