feat(nip17): support gift-wrapped private direct messages #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/nip17-gift-wrap-support"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds NIP-17 (Private Direct Messages) support to the relay so that the
nostrmarket extension's
refactor/nip17-messagingbranch — and anyother client moving from NIP-04 to NIP-17 — can publish and subscribe
to gift-wrapped DMs.
The relay already accepted
kind 1059events as regular kinds (range1000–9999) and the
#pfilter already worked. The remaining gap wasprivacy gating under AUTH: the existing
_is_direct_message_for_otherhook restricted delivery of NIP-04 kind-4 events to the authenticated
recipient, but did nothing for kind 1059. This PR generalizes that hook
so the same opt-in AUTH gate covers gift wraps.
Changes
relay/event.py— addis_seal(kind 13),is_gift_wrap(kind 1059),and
is_private_messagehelpersrelay/client_connection.py— rename_is_direct_message_for_other→_is_private_event_for_other; key offis_private_messageso kinds 4and 1059 share the same recipient-only delivery rule when AUTH is
required for that kind
relay/relay.py— advertise NIPs 17, 44, 59 in NIP-11supported_nipsREADME.md— document NIP-17/44/59 transport-level supporttests/test_nip17.py— unit tests for kind classification, AUTH-gated1059 delivery (recipient vs non-recipient vs unauthenticated), and a
regression check for kind 4 gating
Design notes
recipient-only rule is opt-in via
forcedAuthEvents/requireAuthEvents.Surveyed reference relays (strfry, khatru, nostream) do not enforce
recipient gating for kind 1059 at all — they rely entirely on
client-side encryption. Our config already supports per-kind AUTH, so
this PR keeps that capability and extends it cleanly to 1059.
created_atexemption for gift wraps. NIP-59 backdates wraps upto 2 days. Our
createdAtSecondsPastdefaults to0(no limit), sogift wraps work out of the box. Tracked separately for operators who
configure tighter windows.
payloads as opaque ciphertext and persists them like any regular event.
Out of scope (filed as issues)
#e/#p/#dhardcoded in the filter struct
created_atpast-window exemption for kind 1059 to keepNIP-59 working under strict timestamp configs
category but is stored correctly as a non-ephemeral event
Test plan
make test(the newtests/test_nip17.pyexercises the gatingmatrix;
uvwas not available in the authoring environment so thesuite was syntax-validated only)
forcedAuthEvents: [1059], confirm a gift wrap isdelivered only to the AUTH'd recipient named in the
ptagand the nostrmarket
refactor/nip17-messagingflow round-trips🤖 Generated with Claude Code