feat: mute

This commit is contained in:
codytseng
2025-01-19 14:40:05 +08:00
parent 34ff0cd314
commit cbae26e492
26 changed files with 564 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
import { ISigner, TDraftEvent } from '@/types'
import { finalizeEvent, getPublicKey as nGetPublicKey, nip19 } from 'nostr-tools'
import { finalizeEvent, getPublicKey as nGetPublicKey, nip04, nip19 } from 'nostr-tools'
export class NsecSigner implements ISigner {
private privkey: Uint8Array | null = null
@@ -38,4 +38,18 @@ export class NsecSigner implements ISigner {
return null
}
}
async nip04Encrypt(pubkey: string, plainText: string) {
if (!this.privkey) {
throw new Error('Not logged in')
}
return nip04.encrypt(this.privkey, pubkey, plainText)
}
async nip04Decrypt(pubkey: string, cipherText: string) {
if (!this.privkey) {
throw new Error('Not logged in')
}
return nip04.decrypt(this.privkey, pubkey, cipherText)
}
}