Add profile helpers for newcomers (roadmap #11)

Image upload (ImageField):
- "upload" button next to profile picture and banner URL fields
- Opens native file picker (accept="image/*"), uploads to nostr.build
  free hosting via their v2 API, auto-fills the URL on success
- Shows inline error if upload fails; URL field still editable manually

NIP-05 verification (Nip05Field):
- Replaces the plain nip05 text field
- Debounced live check (900ms): fetches /.well-known/nostr.json?name=...
  and compares the returned pubkey against the logged-in user's pubkey
- Status badges: checking… / ✓ verified / ✗ pubkey mismatch / ✗ not found
- "How to get verified ↗" link to nostr.how guide

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jure
2026-03-10 20:18:18 +01:00
parent 288abdc180
commit abd38a4edd
2 changed files with 139 additions and 4 deletions

23
src/lib/upload.ts Normal file
View File

@@ -0,0 +1,23 @@
/**
* Upload an image file to nostr.build and return the hosted URL.
* nostr.build offers free public image hosting for the Nostr ecosystem.
*/
export async function uploadImage(file: File): Promise<string> {
const form = new FormData();
form.append("fileToUpload", file);
const resp = await fetch("https://nostr.build/api/v2/upload/files", {
method: "POST",
body: form,
});
if (!resp.ok) {
throw new Error(`Upload failed (HTTP ${resp.status})`);
}
const data = await resp.json();
if (data.status === "success" && data.data?.[0]?.url) {
return data.data[0].url as string;
}
throw new Error(data.message || "Upload failed — no URL returned");
}