NIP-04 encryption is deprecated due to security vulnerabilities. This migrates MuteList (kind 10000) and PinnedUsers (kind 10010) private entries to use NIP-44 encryption, with backward compatibility for reading existing NIP-04 encrypted content. When NIP-04 content is detected, it is automatically re-encrypted with NIP-44 and republished to gradually migrate users. Co-Authored-By: captain-stacks <201298974+captain-stacks@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
873 B
TypeScript
42 lines
873 B
TypeScript
import { ISigner } from '@/types'
|
|
import { nip19 } from 'nostr-tools'
|
|
|
|
export class NpubSigner implements ISigner {
|
|
private pubkey: string | null = null
|
|
|
|
login(npub: string) {
|
|
const { type, data } = nip19.decode(npub)
|
|
if (type !== 'npub') {
|
|
throw new Error('invalid nsec')
|
|
}
|
|
this.pubkey = data
|
|
return this.pubkey
|
|
}
|
|
|
|
async getPublicKey() {
|
|
if (!this.pubkey) {
|
|
throw new Error('Not logged in')
|
|
}
|
|
return this.pubkey
|
|
}
|
|
|
|
async signEvent(): Promise<any> {
|
|
throw new Error('Not logged in')
|
|
}
|
|
|
|
async nip04Encrypt(): Promise<any> {
|
|
throw new Error('Not logged in')
|
|
}
|
|
|
|
async nip04Decrypt(): Promise<any> {
|
|
throw new Error('Not logged in')
|
|
}
|
|
|
|
async nip44Encrypt(): Promise<any> {
|
|
throw new Error('Not logged in')
|
|
}
|
|
|
|
async nip44Decrypt(): Promise<any> {
|
|
throw new Error('Not logged in')
|
|
}
|
|
}
|