Commit graph

58 commits

Author SHA1 Message Date
Patrick Mulligan
fd19acff97 fix(nip09): honour a tags in deletion requests
A kind-5 request could only name events by `e` tag. Worse, one that
carried `a` tags and no `e` tags built a filter with an empty id list,
which matched every event by that author and marked them all deleted.

Handle `a` tags per NIP-09: parse `kind:pubkey:d` (the `d` value may
contain ':'), require the pubkey to be the request author and the kind
to be replaceable or addressable, and remove only versions up to the
request's `created_at` so a later re-publication survives. An empty
`d` addresses a replaceable kind.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
(cherry picked from commit e695f9c66881d3d520d40f0cd3e9c95d9435938c)
2026-09-13 17:54:00 +02:00
Patrick Mulligan
d2350f907d test: wait for messages instead of sleeping in the client flow
test_alice_and_bob paused for fixed 0.1-0.5 s between wiring events
and asserting on the replies. On a slow runner the replies were not
there yet; on a fast one the next step ran before the previous event
was stored. Both show up as spurious failures (CI on #45, 2026-09-13).

Give the mock socket a wait_for_messages(count) helper and wait for
the expected number of messages at each step instead. Exact-count
assertions stay, so extra messages still fail.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
(cherry picked from commit deb6510193b68f343c2f7845c615634beb020911)
2026-09-13 17:53:43 +02:00
Patrick Mulligan
06eab1b007 fix: keep every filter of a multi-filter REQ
_handle_request dropped the subscription's existing filters before
adding each filter of a REQ, so a REQ carrying several filters ended
up with only its last one registered. Remove the old filters once per
REQ instead, before the loop, since a REQ replaces the subscription as
a whole.

Also invert _can_add_filter so its name matches what it returns. The
old version returned "limit exceeded" and the caller tested for that,
so behaviour is unchanged; the tests pin it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
(cherry picked from commit 37331b14847cfb5d43f8e97b36a6f52d9b86abae)
2026-09-13 17:53:43 +02:00
4fec1dc826 fix: deliver events to every matching subscription on a connection
notify_event returned after the first filter that matched, so a
connection holding several subscriptions only ever received an event on
one of them. That is invisible with one subscription per client, but a
multiplexer such as nostrclient funnels all of its clients through a
single connection. With nwcprovider subscribed to its own kind-23195
responses, every NWC reply was handed to that subscription and stopped
there; the wallet app's subscription on the same connection never saw
it, and Amethyst reported "wallet request timed out". Direct to the
relay it worked, because the app then had its own connection.

Deliver once per subscription id instead, and demote the per-filter
miss log to debug: it emitted one INFO line per filter per event.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
2026-09-12 14:04:58 +02:00
4811fcf352 feat(nip17): support gift-wrapped private direct messages
Some checks failed
ci.yml / feat(nip17): support gift-wrapped private direct messages (pull_request) Failing after 0s
ci.yml / feat(nip17): support gift-wrapped private direct messages (push) Failing after 0s
Generalize the AUTH-gated, recipient-only delivery rule from NIP-04 to
also cover NIP-17 kind 1059 gift wraps. When the relay is configured to
require AUTH for kind 1059, only the AUTH'd recipient named in the
event's `p` tag receives it; otherwise gift wraps broadcast like any
regular event.

- relay/event.py: add `is_seal`, `is_gift_wrap`, `is_private_message`
  helpers (kinds 13, 1059)
- relay/client_connection.py: rename `_is_direct_message_for_other` ->
  `_is_private_event_for_other`; key off `is_private_message` so the
  same gating applies to kinds 4 and 1059
- relay/relay.py: advertise NIPs 17, 44, 59 in NIP-11 supported_nips
- README: document NIP-17/44/59 transport-level support
- tests/test_nip17.py: unit tests for kind classification, AUTH-gated
  1059 delivery (recipient vs non-recipient vs unauthenticated), and
  regression coverage for kind 4 gating

NIP-44 (encryption) and NIP-59 (wrap/seal) are client-side concerns;
the relay treats payloads as opaque ciphertext and stores kind 1059
like any regular event.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 13:59:14 +02:00
dni ⚡
a53d2d7767
refactor: get rid of secp lib (#40) 2025-11-04 10:30:43 +02:00
dni ⚡
35584a230f
chore: add uv, linting, fixes (#39)
* chore: add uv, linting, fixes
2025-10-30 10:43:27 +01:00
Vlad Stan
3dc066fbd4
[fix] Ws api tests (#31)
Some checks failed
/ release (push) Has been cancelled
/ pullrequest (push) Has been cancelled
2024-11-11 15:25:25 +02:00
dni ⚡
73054fd5ce
feat: update to v1.0.0 (#30) 2024-11-08 15:32:04 +02:00
dni ⚡
cc6752003a
feat: improve codequality and CI (#25)
* feat: improve codequality and CI
2024-08-30 13:20:23 +02:00
Vlad Stan
ffb0177003 chore: code format 2023-02-21 16:20:19 +02:00
Vlad Stan
7ec3045130 feat: add extension clean-up endpoint 2023-02-17 14:57:31 +02:00
Vlad Stan
230729483c chore: code format 2023-02-17 14:44:39 +02:00
Vlad Stan
855812cb8f refactor: extract NostrRelay 2023-02-17 14:44:39 +02:00
Vlad Stan
2ebc83a286 refactor: extract NostrFilter 2023-02-17 14:44:39 +02:00
Vlad Stan
6be0169ea9 refactor: extract NostrEvent 2023-02-17 14:44:39 +02:00
Vlad Stan
c42d81f696 refactor: extract client_connection 2023-02-17 14:44:39 +02:00
Vlad Stan
aa68d2a79a refactor: extract EventValidator 2023-02-17 14:44:39 +02:00
Vlad Stan
c46c903703 refactor: move client-manager 2023-02-17 14:44:39 +02:00
Vlad Stan
d5d8b5e1b5 refactor: init callbacks 2023-02-17 14:44:39 +02:00
Vlad Stan
5c0209b6c0 feat: finish NIP16 2023-02-17 09:55:23 +02:00
Vlad Stan
bc1af610db chore: mypy fixes 2023-02-15 18:18:46 +02:00
Vlad Stan
d5aff47717 refactor: class renamings 2023-02-10 13:40:15 +02:00
Vlad Stan
1eda457067 chore: force py format 2023-02-10 12:16:25 +02:00
Vlad Stan
534cf04210 feat: use RelayConfig for active relays 2023-02-08 10:21:26 +02:00
Vlad Stan
4e5c2657c9 chore: code format 2023-02-08 08:50:07 +02:00
Vlad Stan
14df3a6ffb tests: update after changes 2023-02-07 18:15:43 +02:00
Vlad Stan
5a747361af feat: make event kind: 3 replaceable 2023-02-06 12:09:53 +02:00
Vlad Stan
10ef9ee2ac feat: on meta update, replace old meta 2023-02-06 11:10:14 +02:00
Vlad Stan
5ca27ff28a fix: ok -> OK upper case 2023-02-03 18:17:41 +02:00
Vlad Stan
d27ece735e fix: NIP20 duplicate event 2023-02-03 17:42:10 +02:00
Vlad Stan
01764c155e feat: add delete post tests 2023-02-03 15:45:23 +02:00
Vlad Stan
6b11221205 test: direct messages 2023-02-03 11:32:44 +02:00
Vlad Stan
30ed35a14e test: bob writes direct message to alice 2023-02-03 11:07:17 +02:00
Vlad Stan
96f8f9927d refactor: method renames 2023-02-03 10:21:11 +02:00
Vlad Stan
c4b498c28c refactor: make code more readable 2023-02-03 10:14:28 +02:00
Vlad Stan
3d1511a545 refactor: extract fixtures 2023-02-03 09:58:50 +02:00
Vlad Stan
f183027811 fix: missing param 2023-02-03 09:48:16 +02:00
Vlad Stan
78de195354 test: notifications 2023-02-03 09:47:12 +02:00
Vlad Stan
e87d43d21a test: bob_reacts_to_posts_alice_receives_notifications 2023-02-03 09:23:43 +02:00
Vlad Stan
4766e8daaf test: notify likes 2023-02-02 18:43:46 +02:00
Vlad Stan
cae1bb146a test: notifications 2023-02-02 17:20:35 +02:00
Vlad Stan
f96945c694 test: follow Alice 2023-02-02 16:53:01 +02:00
Vlad Stan
841b8d6ea4 test: more fixtures 2023-02-02 16:27:06 +02:00
Vlad Stan
f6c92a5ccf test: first fixtures 2023-02-02 15:15:13 +02:00
Vlad Stan
90cdfc61fb test: wip 2023-02-02 11:32:29 +02:00
Vlad Stan
855ec09df3 refactor: code clean-up 2023-02-02 10:26:25 +02:00
Vlad Stan
d4bfb0a815 test: add tests for filtering 2023-02-02 10:24:12 +02:00
Vlad Stan
80ae3db4c1 refactor: extract more methods 2023-02-02 09:39:12 +02:00
Vlad Stan
09424b0de9 refactor: extract methods 2023-02-02 09:32:30 +02:00