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
fiatjaf
ff3bf4a51c
improvements and fixes on pool.
2023-02-09 12:05:31 -03:00
fiatjaf
7ff97b5488
list() and get() methods.
2023-02-08 16:37:53 -03:00
fiatjaf
75d7be5a54
use per-subscription alreadyHaveEvent handler instead of per-relay.
...
now pools are much smarter.
2023-02-08 14:15:54 -03:00
fiatjaf
4485c8ed5e
remove broken globalThis error type.
2023-02-08 14:15:54 -03:00
fiatjaf
da59e3ce90
when in pool, automatically and efficiently deduplicate.
2023-02-08 09:46:05 -03:00
gaodeng
9082953ede
fix error event
2023-02-07 06:03:41 -03:00
fiatjaf
26089ef958
refactor previous commit a little, add fakejson module for simple parsing that doesn't use regex.
2023-01-22 10:32:33 -03:00
Martti Malmi
2e305b7cd4
incoming message queue, alreadyHaveEvent check, msg.send catch
2023-01-21 07:03:12 -03:00
Tristan
8071e2f4fa
Make `opts` arg optional for `sub` method
...
In the README and the code, it looks like the second argument for the relay's `sub` method is optional:
```typescript
let sub = relay.sub([
{
ids: ['d7dd5eb3ab747e16f8d0212d53032ea2a7cadef53837e5a6c66d42849fcb9027']
}
])
```
In the type definitions it's required however, which leads to an error in editors. Let's mark it as optional in the type definitions too! 👍
2022-12-25 14:32:20 -03:00
Tristan
cc2250da1f
Add missing "error" event to `on` and `off` type definitions
2022-12-25 14:31:38 -03:00
rkfg
c37d10bb9d
Fix resolveClose
2022-12-24 20:41:49 -03:00
rkfg
97e28fdf9a
Fix connect/close return types and race condition
2022-12-24 18:49:16 -03:00
fiatjaf
74a0d5454a
guard against some nonexisting arrays of event listeners.
2022-12-23 15:18:23 -03:00