add interface for getRelays() and bump version.

This commit is contained in:
fiatjaf
2022-02-15 16:15:27 -03:00
parent 414c0ea337
commit 259a37d4d7
4 changed files with 22 additions and 11 deletions

View File

@@ -12,6 +12,20 @@ window.nostr = {
return this._call('signEvent', {event})
},
async getRelays() {
return this._call('getRelays', {})
},
nip04: {
async encrypt(peer, plaintext) {
return window.nostr._call('nip04.encrypt', {peer, plaintext})
},
async decrypt(peer, ciphertext) {
return window.nostr._call('nip04.decrypt', {peer, ciphertext})
}
},
_call(type, params) {
return new Promise((resolve, reject) => {
let id = Math.random().toString().slice(4)
@@ -26,16 +40,6 @@ window.nostr = {
'*'
)
})
},
nip04: {
encrypt(peer, plaintext) {
return window.nostr._call('nip04.encrypt', {peer, plaintext})
},
decrypt(peer, ciphertext) {
return window.nostr._call('nip04.decrypt', {peer, ciphertext})
}
}
}