nostr-tools
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "nostr-tools", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Tools for making a Nostr client.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
19
relay.js
@@ -35,8 +35,22 @@ import PersistentWebSocket from 'pws' | ||
ws.onmessage = async e => { | ||
let data = JSON.parse(e.data) | ||
var data | ||
try { | ||
data = JSON.parse(e.data) | ||
} catch (err) { | ||
data = e.data | ||
} | ||
if (data.length > 1) { | ||
if (data === 'PING') { | ||
ws.send('PONG') | ||
return | ||
} | ||
if (data[0] === 'notice') { | ||
console.log('message from relay ' + url + ': ' + data[1]) | ||
onNotice(data[1]) | ||
} else if (typeof data[0] === 'object') { | ||
return | ||
} | ||
if (typeof data[0] === 'object') { | ||
let event = data[0] | ||
@@ -54,2 +68,3 @@ let context = data[1] | ||
} | ||
return | ||
} | ||
@@ -56,0 +71,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import secp256k1 from 'noble-secp256k1' | ||
import * as secp256k1 from 'noble-secp256k1' | ||
@@ -3,0 +3,0 @@ export const makeRandom32 = () => secp256k1.utils.randomPrivateKey() |
9572
270