Improve NIP-98 error messages and disable nostrimg.com by default
**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
This commit is contained in:
parent
015117686b
commit
2b5df250f6
@ -42,7 +42,7 @@ export const DEFAULT_NIP95_APIS: Nip95Config[] = [
|
|||||||
{
|
{
|
||||||
id: 'nostrimg',
|
id: 'nostrimg',
|
||||||
url: 'https://nostrimg.com/api/upload',
|
url: 'https://nostrimg.com/api/upload',
|
||||||
enabled: true,
|
enabled: false, // Disabled by default due to server errors (500)
|
||||||
priority: 1,
|
priority: 1,
|
||||||
createdAt: Date.now(),
|
createdAt: Date.now(),
|
||||||
},
|
},
|
||||||
|
|||||||
12
lib/nip95.ts
12
lib/nip95.ts
@ -1,6 +1,8 @@
|
|||||||
import type { MediaRef } from '@/types/nostr'
|
import type { MediaRef } from '@/types/nostr'
|
||||||
import { getEnabledNip95Apis } from './config'
|
import { getEnabledNip95Apis } from './config'
|
||||||
import { generateNip98Token, isNip98Available } from './nip98'
|
import { generateNip98Token, isNip98Available } from './nip98'
|
||||||
|
import { nostrService } from './nostr'
|
||||||
|
import { nostrAuthService } from './nostrAuth'
|
||||||
|
|
||||||
const MAX_IMAGE_BYTES = 5 * 1024 * 1024
|
const MAX_IMAGE_BYTES = 5 * 1024 * 1024
|
||||||
const MAX_VIDEO_BYTES = 45 * 1024 * 1024
|
const MAX_VIDEO_BYTES = 45 * 1024 * 1024
|
||||||
@ -131,7 +133,15 @@ export async function uploadNip95Media(file: File): Promise<MediaRef> {
|
|||||||
|
|
||||||
if (needsAuth) {
|
if (needsAuth) {
|
||||||
if (!isNip98Available()) {
|
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
|
continue
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user