70 Commits

Author SHA1 Message Date
Chris McCormick
bc1294e4e6 Reconnect with exponential backoff flag: enableReconnect (#507)
https://github.com/nbd-wtf/nostr-tools/pull/507
2025-09-30 10:01:07 -03:00
Chris McCormick
226d7d07e2 Improvements to enablePing() & tests (#506)
https://github.com/nbd-wtf/nostr-tools/pull/506
2025-09-29 10:41:40 -03:00
fiatjaf
ae2f97655b remove two deprecated things. 2025-05-31 20:04:46 -03:00
fiatjaf
87a91c2daf fix useWebSocketImplementation so it works with pool on nodejs esm. 2024-05-29 13:39:00 -03:00
Anderson Juhasc
4f1dc9ef1c fixing formatting with Prettier 2024-05-27 10:44:44 -03:00
António Conselheiro
88454de628 including interface for nip07 (#403)
* including interface for nip07

* fix types for NIP-07

* including NIP-07 export to jsr

* fix readme about nip07

* including in nip7 interface an output signature compatible with the event returned by the signer
2024-05-26 11:58:12 -03:00
Alex Gleason
9c0ade1329 Fix (most) slow types by adding explicit return types 2024-03-07 07:22:44 -03:00
fiatjaf
daaa2ef0a1 bring back relayConnect() as deprecated. 2023-12-21 19:59:12 -03:00
fiatjaf
7f11c0c618 unsplit, backwards-compatibility, wasm relay and pool must be configured manually from the abstract classes. 2023-12-21 19:57:28 -03:00
fiatjaf
a4ae964ee6 split relay and pool into pure and wasm modules. 2023-12-21 17:27:42 -03:00
jiftechnify
b7389be5c7 correctly wait until connection to a relay is established 2023-12-20 14:43:33 -03:00
fiatjaf
0cc3c02d84 fix fix yield. 2023-12-20 10:49:08 -03:00
Shusui MOYATANI
8625d45152 fix yield 2023-12-20 09:27:49 -03:00
fiatjaf
fe87529646 change tests and nips to use the new api. 2023-12-19 13:58:37 -03:00
fiatjaf
71b412657f .subscribe() is not async. 2023-12-19 10:22:29 -03:00
fiatjaf
8840c4d8e2 final adjustments and now even the flaky tests that depend on others's relay should pass most of the time. 2023-12-19 10:01:52 -03:00
fiatjaf
804403f574 change the way eose and connection timeouts work. 2023-12-18 17:11:16 -03:00
fiatjaf
88703e9ea2 update readme with new api. 2023-12-17 22:46:35 -03:00
fiatjaf
3bfb50e267 rewrite pool.ts to be much simpler. 2023-12-17 11:19:50 -03:00
fiatjaf
420a6910e9 fix Queue, tweaks on relay.ts and make relay.test.ts pass. 2023-12-17 00:27:03 -03:00
fiatjaf
7a640092d0 rewrite relay.ts to be much simpler. 2023-12-16 18:56:18 -03:00
fiatjaf
6a07e7c1cc remove the kind type parameter from events and filters. 2023-12-16 10:10:37 -03:00
fiatjaf
13bc2ad5a8 trick typescript into accepting our types. 2023-09-10 15:44:22 -03:00
Alex Gleason
c18f050468 relay: sub.events async iterator 2023-09-09 19:05:21 -03:00
Egge
e9eac28bab Added eoseSubTimeout to pool's SubscriptionOptions (#284)
* added timeout sub option

* made eoseSubTimeout optional
2023-09-01 07:50:12 -03:00
Alex Gleason
718032022c just format 2023-08-31 13:42:15 -05:00
fiatjaf
9efdd16e26 fix check for undefined ws
fixes https://github.com/nbd-wtf/nostr-tools/issues/271
2023-08-11 07:09:40 -03:00
fiatjaf
9d690814ca turn .publish() into a normal async function returning a promise.
this simplifies the code and makes the API more intuitive.

we used to need the event emitter thing because we were subscribing to the same relay
to check if the event had been published, but that is not necessary now that we assume
an OK response will always come.

closes https://github.com/nbd-wtf/nostr-tools/issues/262
2023-07-30 18:23:05 -03:00
Egge
5b15237b95 replace ArrayList with Queue 2023-05-16 17:16:38 +02:00
Alex Gleason
08885ab8da Refactor imports: use file extension, improve tree shaking, update tests 2023-05-12 17:03:41 -03:00
Alex Gleason
d0bd599ce8 Infer relay event types from filter 2023-05-06 20:59:39 -03:00
fiatjaf
bf7e00d32a hotfix types. 2023-04-18 15:29:28 -03:00
Lynn Zenn
32c47e9bd8 relay: separate auth() and publish() methods 2023-04-18 15:16:40 -03:00
Lynn Zenn
6e58fe371c relay: add support for NIP42 authentication 2023-04-18 15:16:40 -03:00
Lynn Zenn
26e35d50e0 relay: fix type errors 2023-04-18 15:16:40 -03:00
Jonathan Staab
f1bb5030c8 Add support for count 2023-04-16 06:43:38 -03:00
Steve Perkins
f1eb9a3bc7 Reuse connectionPromise for relay connect. 2023-04-04 08:10:51 -03:00
fiatjaf
5733f9c4e4 reject promise on WebSocket initiation failure. 2023-03-19 09:07:16 -03:00
BilligsterUser
6b73bbf8a3 Type sub event handler (#156)
* RelayEvent allow Promises

* type Sub EventHandler

* Update relay.ts
2023-03-12 08:51:38 -03:00
BilligsterUser
d244b62c7a type Relay EventHandler (#121)
* type Relay EventHandler

* Update relay.ts
2023-03-11 15:24:52 -03:00
ramigs
82228036ef close relay's websocket only if it's in state OPEN 2023-03-04 12:57:50 -03:00
fiatjaf
9d345a8f01 configurable list and get timeout on relay. 2023-02-26 21:23:09 -03:00
fiatjaf
a8938a3a0f wait a second before failing to send on a not yet connected websocket. 2023-02-26 16:53:03 -03:00
Fernando López Guevara
f43d23d344 fix(relay): prevent accesing to ws if it is undefined 2023-02-23 15:20:10 -03:00
fiatjaf
3d93ec8446 remove resolveClose, close() is now fire-and-forget. 2023-02-17 14:51:56 -03:00
fiatjaf
24406b5679 more automatic cleanup of event listeners. 2023-02-15 20:36:22 -03:00
fiatjaf
6dbcc87d93 delete listeners when closing a relay connection. 2023-02-15 20:31:25 -03:00
fiatjaf
0ddcfdce68 remove "seen" event from Pub.
too complicated. if anyone wants this they can do it themselves.
2023-02-15 20:21:29 -03:00
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
9bcaed6e60 fix tests, .seenOn() method for pools. 2023-02-09 22:01:01 -03:00