Compare commits

..

4 Commits

Author SHA1 Message Date
fiatjaf
f04bc0cee1 fix filter on statusCallback: id -> ids 2022-02-15 21:03:44 -03:00
fiatjaf
e63479ee7f nip05 more strict. enforce the presence of "_" for domain names. 2022-02-12 20:37:23 -03:00
fiatjaf
c47f091d9b update noble secp256k1 and ensure we always return hex. 2022-02-11 16:27:23 -03:00
Melvin Carvalho
4c785279bc remove => from onEvent function in README.md. 2022-02-03 09:31:03 -03:00
6 changed files with 9 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ pool.addRelay('ws://some.relay.com', {read: true, write: true})
pool.addRelay('ws://other.relay.cool', {read: true, write: true})
// example callback function for a subscription
function onEvent(event, relay) => {
function onEvent(event, relay) {
console.log(`got an event from ${relay.url} which is already validated.`, event)
}

View File

@@ -52,5 +52,7 @@ export function verifySignature(event) {
}
export async function signEvent(event, key) {
return secp256k1.schnorr.sign(getEventHash(event), key)
return Buffer.from(
await secp256k1.schnorr.sign(getEventHash(event), key)
).toString('hex')
}

View File

@@ -5,5 +5,5 @@ export function generatePrivateKey() {
}
export function getPublicKey(privateKey) {
return secp256k1.schnorr.getPublicKey(privateKey)
return Buffer.from(secp256k1.schnorr.getPublicKey(privateKey)).toString('hex')
}

View File

@@ -15,11 +15,7 @@ export async function searchDomain(domain, query = '') {
export async function queryName(fullname) {
try {
let [name, domain] = fullname.split('@')
if (!domain) {
domain = name
name = '_'
}
if (!domain) return null
let res = await (
await fetch(`https://${domain}/.well-known/nostr.json?name=${name}`)

View File

@@ -1,6 +1,6 @@
{
"name": "nostr-tools",
"version": "0.21.4",
"version": "0.22.2",
"description": "Tools for making a Nostr client.",
"repository": {
"type": "git",
@@ -8,7 +8,7 @@
},
"dependencies": {
"@noble/hashes": "^0.5.7",
"@noble/secp256k1": "^1.3.0",
"@noble/secp256k1": "^1.5.2",
"browserify-cipher": ">=1",
"buffer": ">=5",
"create-hash": "^1.2.0",

View File

@@ -160,7 +160,7 @@ export function relayConnect(url, onNotice = () => {}, onError = () => {}) {
unsub()
clearTimeout(willUnsub)
},
filter: {id: event.id}
filter: {ids: [event.id]}
},
`monitor-${event.id.slice(0, 5)}`
)