refactor: remove electron-related code
This commit is contained in:
26
src/providers/NostrProvider/nip-07.signer.ts
Normal file
26
src/providers/NostrProvider/nip-07.signer.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { ISigner, TDraftEvent, TNip07 } from '@/types'
|
||||
|
||||
export class Nip07Signer implements ISigner {
|
||||
private signer: TNip07
|
||||
private pubkey: string | null = null
|
||||
|
||||
constructor() {
|
||||
if (!window.nostr) {
|
||||
throw new Error(
|
||||
'You need to install a nostr signer extension to login. Such as alby, nostr-keyx or nos2x.'
|
||||
)
|
||||
}
|
||||
this.signer = window.nostr
|
||||
}
|
||||
|
||||
async getPublicKey() {
|
||||
if (!this.pubkey) {
|
||||
this.pubkey = await this.signer.getPublicKey()
|
||||
}
|
||||
return this.pubkey
|
||||
}
|
||||
|
||||
async signEvent(draftEvent: TDraftEvent) {
|
||||
return await this.signer.signEvent(draftEvent)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user