chore(api): remove User.prvkey field + thread-through helpers (Q1.2 Option b) #84

Merged
padreug merged 1 commit from chore/remove-user-prvkey-field into dev 2026-06-03 16:33:49 +00:00
4 changed files with 20 additions and 17 deletions

View file

@ -40,8 +40,12 @@ interface User {
username?: string username?: string
email?: string email?: string
pubkey?: string pubkey?: string
// pragma: allowlist secret // The `prvkey` field was removed from this interface as the final step of
prvkey?: string // Nostr signing key for user // phase-1 per aiolabs/lnbits#9 / design-questions Q1.2 Option (b). LNbits
// signs server-side via the NostrSigner abstraction (PR #26) and exposes
// `signer_type` instead of raw key material on /api/v1/auth. Bucket-B
// sign-sites (kind 1 / 4 / 5 / 7 / 31925 / 10003 / 1111 etc.) migrate to
// POST /api/v1/auth/sign-event (PR #29) in phase 2.
external_id?: string external_id?: string
extensions: string[] extensions: string[]
wallets: Wallet[] wallets: Wallet[]
@ -175,19 +179,21 @@ export class LnbitsAPI extends BaseService {
// First get basic user info from /auth // First get basic user info from /auth
const basicUser = await this.request<User>('/auth') const basicUser = await this.request<User>('/auth')
// Then get Nostr keys from /auth/nostr/me (this was working in main branch) // /auth/nostr/me used to return the user's prvkey for client-side signing;
// post-aiolabs/lnbits#9 phase-1 the server signs and the endpoint returns
// only the pubkey. We keep the call to merge the pubkey (which the basic
// /auth response also includes on the post-cascade server; this is the
// belt-and-suspenders fallback for older lnbits revisions until we ship a
// signer_type-aware client).
try { try {
const nostrUser = await this.request<User>('/auth/nostr/me') const nostrUser = await this.request<User>('/auth/nostr/me')
// Merge the data - basic user info + Nostr keys
return { return {
...basicUser, ...basicUser,
pubkey: nostrUser.pubkey, pubkey: nostrUser.pubkey,
prvkey: nostrUser.prvkey
} }
} catch (error) { } catch (error) {
console.warn('Failed to fetch Nostr keys, returning basic user info:', error) console.warn('Failed to fetch Nostr pubkey from /auth/nostr/me, returning basic user info:', error)
// Return basic user info without Nostr keys if the endpoint fails
return basicUser return basicUser
} }
} }

View file

@ -180,17 +180,14 @@ export class AuthService extends BaseService {
this.isLoading.value = true this.isLoading.value = true
const updatedUser = await this.lnbitsAPI.updateProfile(data) const updatedUser = await this.lnbitsAPI.updateProfile(data)
// Preserve prvkey and pubkey from existing user since /auth/update doesn't return them // Preserve pubkey from existing user since /auth/update doesn't return it.
// Kind-0 metadata is published server-side by lnbits's PATCH /auth handler
// (aiolabs/lnbits commit 869f67c3); no webapp-side broadcast path remains.
this.user.value = { this.user.value = {
...updatedUser, ...updatedUser,
pubkey: this.user.value?.pubkey || updatedUser.pubkey, pubkey: this.user.value?.pubkey || updatedUser.pubkey,
prvkey: this.user.value?.prvkey || updatedUser.prvkey
} }
// Kind-0 metadata is published server-side by lnbits's PATCH /auth handler
// (aiolabs/lnbits commit 869f67c3) once the cascade is deployed. The webapp
// no longer maintains its own broadcast path.
} catch (error) { } catch (error) {
const err = this.handleError(error, 'updateProfile') const err = this.handleError(error, 'updateProfile')
throw err throw err

View file

@ -18,7 +18,7 @@ import ThreadedPost from './ThreadedPost.vue'
import ScheduledEventCard from './ScheduledEventCard.vue' import ScheduledEventCard from './ScheduledEventCard.vue'
import appConfig from '@/app.config' import appConfig from '@/app.config'
import type { ContentFilter, FeedPost } from '../services/FeedService' import type { ContentFilter, FeedPost } from '../services/FeedService'
import type { ScheduledEvent } from '../services/ScheduledEventService' import type { ScheduledEvent } from '@/modules/tasks/services/TaskService'
import { injectService, SERVICE_TOKENS } from '@/core/di-container' import { injectService, SERVICE_TOKENS } from '@/core/di-container'
import type { AuthService } from '@/modules/base/auth/auth-service' import type { AuthService } from '@/modules/base/auth/auth-service'
import type { RelayHub } from '@/modules/base/nostr/relay-hub' import type { RelayHub } from '@/modules/base/nostr/relay-hub'

View file

@ -17,7 +17,7 @@ import {
CollapsibleTrigger, CollapsibleTrigger,
} from '@/components/ui/collapsible' } from '@/components/ui/collapsible'
import { Calendar, MapPin, Clock, CheckCircle, PlayCircle, Hand, Trash2 } from 'lucide-vue-next' import { Calendar, MapPin, Clock, CheckCircle, PlayCircle, Hand, Trash2 } from 'lucide-vue-next'
import type { ScheduledEvent, EventCompletion, TaskStatus } from '../services/ScheduledEventService' import type { ScheduledEvent, EventCompletion, TaskStatus } from '@/modules/tasks/services/TaskService'
import { injectService, SERVICE_TOKENS } from '@/core/di-container' import { injectService, SERVICE_TOKENS } from '@/core/di-container'
import type { AuthService } from '@/modules/base/auth/auth-service' import type { AuthService } from '@/modules/base/auth/auth-service'