Compare commits

..

7 Commits

Author SHA1 Message Date
fiatjaf
32793146a4 remove untilOpen promise that was causing memory leaks when a connection was never opened. 2023-02-14 11:24:30 -03:00
fiatjaf
c42cd925ce bump noble-hashes. 2023-02-13 21:26:42 -03:00
RbnRncn
43ccb72476 docs: import SimplePool fix
Small fix of import SimplePool in new multiple relay docs.
2023-02-12 08:41:22 -03:00
fiatjaf
b2b7999517 notice about just.
closes https://github.com/nbd-wtf/nostr-tools/pull/106
2023-02-09 22:02:07 -03:00
fiatjaf
a568afc295 remove this extraneous file. 2023-02-09 22:01:01 -03:00
fiatjaf
9bcaed6e60 fix tests, .seenOn() method for pools. 2023-02-09 22:01:01 -03:00
Fernando López Guevara
5a9cbbb557 feat(deps): upgrade dependencies 2023-02-09 21:59:37 -03:00
3 changed files with 21 additions and 21 deletions

View File

@@ -128,7 +128,7 @@ import 'websocket-polyfill'
### Interacting with multiple relays
```js
import {pool} from 'nostr-tools'
import {SimplePool} from 'nostr-tools'
const pool = new SimplePool()
@@ -293,6 +293,11 @@ Please consult the tests or [the source code](https://github.com/fiatjaf/nostr-t
</script>
```
## Plumbing
1. Install [`just`](https://just.systems/)
2. `just -l`
## License
Public domain.

View File

@@ -1,6 +1,6 @@
{
"name": "nostr-tools",
"version": "1.3.2",
"version": "1.4.1",
"description": "Tools for making a Nostr client.",
"repository": {
"type": "git",
@@ -9,11 +9,12 @@
"main": "lib/nostr.cjs.js",
"module": "lib/nostr.esm.js",
"dependencies": {
"@noble/hashes": "^0.5.7",
"@noble/secp256k1": "^1.7.0",
"@noble/hashes": "1.0.0",
"@noble/secp256k1": "^1.7.1",
"@scure/base": "^1.1.1",
"@scure/bip32": "^1.1.1",
"@scure/bip39": "^1.1.0"
"@scure/bip32": "^1.1.5",
"@scure/bip39": "^1.1.1",
"prettier": "^2.8.4"
},
"keywords": [
"decentralization",
@@ -23,20 +24,20 @@
"nostr"
],
"devDependencies": {
"@types/node": "^18.0.3",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1",
"@types/node": "^18.13.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"esbuild": "0.16.9",
"esbuild-plugin-alias": "^0.2.1",
"eslint": "^8.30.0",
"eslint": "^8.33.0",
"eslint-plugin-babel": "^5.3.1",
"esm-loader-typescript": "^1.0.1",
"esm-loader-typescript": "^1.0.3",
"events": "^3.3.0",
"jest": "^29.3.1",
"node-fetch": "2",
"ts-jest": "^29.0.3",
"jest": "^29.4.2",
"node-fetch": "^2.6.9",
"ts-jest": "^29.0.5",
"tsd": "^0.22.0",
"typescript": "^4.9.4",
"typescript": "^4.9.5",
"websocket-polyfill": "^0.0.3"
}
}

View File

@@ -38,10 +38,6 @@ export type SubscriptionOptions = {
export function relayInit(url: string): Relay {
var ws: WebSocket
var resolveClose: () => void
var setOpen: (value: PromiseLike<void> | void) => void
var untilOpen = new Promise<void>(resolve => {
setOpen = resolve
})
var openSubs: {[id: string]: {filters: Filter[]} & SubscriptionOptions} = {}
var listeners: {
connect: Array<() => void>
@@ -74,7 +70,6 @@ export function relayInit(url: string): Relay {
ws.onopen = () => {
listeners.connect.forEach(cb => cb())
setOpen()
resolve()
}
ws.onerror = () => {
@@ -171,7 +166,6 @@ export function relayInit(url: string): Relay {
async function trySend(params: [string, ...any]) {
let msg = JSON.stringify(params)
await untilOpen
try {
ws.send(msg)
} catch (err) {