mirror of
https://github.com/hoornet/vega.git
synced 2026-05-11 06:39:10 -07:00
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:
23
src/lib/upload.ts
Normal file
23
src/lib/upload.ts
Normal 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");
|
||||
}
|
||||
Reference in New Issue
Block a user