From 2b5df250f630e00bd35cf0500243a89a48e761f0 Mon Sep 17 00:00:00 2001 From: Nicolas Cantu Date: Mon, 5 Jan 2026 22:53:45 +0100 Subject: [PATCH] Improve NIP-98 error messages and disable nostrimg.com by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Motivations:** - Provide clearer error messages when NIP-98 authentication is not available - Disable nostrimg.com by default since it returns server errors (500) - Help users understand why nostrcheck.me endpoint is skipped **Root causes:** - NIP-98 authentication requires unlocked account but error message was generic - nostrimg.com endpoint consistently returns 500 errors - Users don't understand why nostrcheck.me is skipped **Correctifs:** - Added detailed error messages for NIP-98 unavailability: - No account: 'Please create or import an account' - Account not unlocked: 'Please unlock your account with your recovery phrase' - Disabled nostrimg.com by default (enabled: false) due to server errors - Improved console warnings with specific reasons for skipping endpoints **Evolutions:** - None **Pages affectées:** - lib/nip95.ts - lib/configStorageTypes.ts --- lib/configStorageTypes.ts | 2 +- lib/nip95.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/configStorageTypes.ts b/lib/configStorageTypes.ts index e04fc9a..ce072cb 100644 --- a/lib/configStorageTypes.ts +++ b/lib/configStorageTypes.ts @@ -42,7 +42,7 @@ export const DEFAULT_NIP95_APIS: Nip95Config[] = [ { id: 'nostrimg', url: 'https://nostrimg.com/api/upload', - enabled: true, + enabled: false, // Disabled by default due to server errors (500) priority: 1, createdAt: Date.now(), }, diff --git a/lib/nip95.ts b/lib/nip95.ts index eace907..e9b7a2f 100644 --- a/lib/nip95.ts +++ b/lib/nip95.ts @@ -1,6 +1,8 @@ import type { MediaRef } from '@/types/nostr' import { getEnabledNip95Apis } from './config' import { generateNip98Token, isNip98Available } from './nip98' +import { nostrService } from './nostr' +import { nostrAuthService } from './nostrAuth' const MAX_IMAGE_BYTES = 5 * 1024 * 1024 const MAX_VIDEO_BYTES = 45 * 1024 * 1024 @@ -131,7 +133,15 @@ export async function uploadNip95Media(file: File): Promise { if (needsAuth) { if (!isNip98Available()) { - console.warn('NIP-98 authentication required for nostrcheck.me but not available. Skipping endpoint.') + const pubkey = nostrService.getPublicKey() + const isUnlocked = nostrAuthService.isUnlocked() + if (!pubkey) { + console.warn('NIP-98 authentication required for nostrcheck.me but no account found. Please create or import an account.') + } else if (!isUnlocked) { + console.warn('NIP-98 authentication required for nostrcheck.me but account is not unlocked. Please unlock your account with your recovery phrase to use this endpoint.') + } else { + console.warn('NIP-98 authentication required for nostrcheck.me but not available. Skipping endpoint.') + } continue } try {