Enable NIP-17 inbox relay after next strfry release #661
Open
opened 2026-08-10 16:06:02 +00:00 by raucao
·
1 comment
No Branch/Tag Specified
Labels
Clear labels
monitoring
bug
design
dev environment
docs
duplicate
enhancement
feature
good first issue
idea
invalid
kredits-1
kredits-2
kredits-3
on hold
ops
question
security
ui/ux
wontfix
service
discourse
Kosmos Community Forums
Infrastructure metrics, alerts, notifications, etc.
service
accounts
Kosmos Accounts
service
drone-ci
Kosmos Drone CI
service
email
mail.kosmos.org
service
garage
S3-compatible object storage
service
gitea
Kosmos Gitea
service
ipfs
Kosmos IPFS
service
lightning
Lightning address, lndhub, etc.
service
mastodon
kosmos.social
service
nostr
Relays, Blossom server, etc.
service
postgres
Database cluster
service
remotestorage
Portable data storage for the Web
service
wiki
Kosmos Wiki
service
xmpp
Kosmos Chat
Something is not working
Graphic/visual design
Config, builds, CI, deployment, etc.
Documentation
This issue or pull request already exists
Improving existing functionality
New functionality
Dive in, and start contributing
Something to consider
Not a bug
Small contribution
Medium contribution
Large contribution
Currently not actionable
Manual IT ops activities
Looking for an answer
release
major
release
minor
release
patch
All your base are belong to us
User interface, process design, etc.
This won't be fixed
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: kosmos/chef#661
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Goal
Use strfry as a NIP-17 inbox relay: accept giftwraps (kind 1059) addressed to our users, and only serve them to the authenticated recipient.
Current state — blocked on upstream
We're pinned to strfry 1.1.1 (
site-cookbooks/strfry/attributes/default.rb:2). 1.1.1 only has a write-policy plugin; there is no read-side policy:filterValidation(src/filters.h) validates the shape of REQ filters (allowedKinds,requireAuthorOrTag) but has no access to the authenticated pubkey, so it cannot enforce "only the recipient can read their giftwraps."authedis only surfaced to the write plugin for NIP-70 protected events (src/apps/relay/RelayIngester.cpp).REQ {"kinds":[1059],"#p":["<victim>"]}and pull all stored giftwraps (ciphertext + metadata leak).Confirmed by upstream issue #228 "Auth on DMs Req" (open).
Dependency — wait for an upstream strfry release tag
PR #250 "Restricted reads" was merged to
masteron Aug 5 2026 by the maintainer (Doug Hoyte). It adds exactly what we need:relay.auth.restrictedReadKinds— kinds that require NIP-42 AUTH to read via REQ/COUNT/NEG-OPEN. A filter with nokindsfield is treated as restricted.relay.auth.restrictReadToInvolvedPubkey = true— for restricted kinds, the authed pubkey must be in the filter'sauthors/#pset, and per-event delivery is gated byReadRestrictor::shouldSendToSubscriber(src/ReadRestrictor.h): an event is only delivered if the authed subscriber == the event'sp-tag recipient (or the author).Also already on master: PR #251 "Allow gift-wrap recipients to delete via NIP-09 (NIP-59)".
Block this issue until an upstream strfry release tag including #250 is cut. Then bump
node["strfry"]["revision"]insite-cookbooks/strfry/attributes/default.rb:2to that tag.Decision
mastercommit.1059only (NIP-59 giftwraps).Tasks
site-cookbooks/strfry/attributes/default.rb: bumpnode["strfry"]["revision"]to the new release tag (once available).site-cookbooks/strfry/templates/default/strfry.conf.erb: add the two newrelay.authkeys —restrictedReadKindsandrestrictReadToInvolvedPubkey(mirror upstreamstrfry.conf; defaults""/true).environments/production.json(strfry.config.relay): setauth.enabled = trueauth.service_url = "wss://nostr.kosmos.org"auth.restricted_read_kinds = "1059"auth.restrict_read_to_involved_pubkey = trueinfo.nips.akkountsrepoextras/strfry/ldap-policy.ts(pulled bysite-cookbooks/kosmos_strfry/recipes/policies.rb:70): special-case kind 1059 — accept if anyp-tag matches a Kosmos user in LDAP (nostrKey=…), bypassing the author check (giftwraps are signed by a one-time random key). Keep thewhitelist_pubkeysshort-circuit.{}REQs over kind 1059. WithrestrictedReadKinds="1059", a wildcardREQ {}is treated as restricted → unauthenticated clients get challenged/closed (fail-closed). Note:node["substr"]["relay_urls"] = ["ws://localhost:7777"](environments/production.json).knife zero converge name:strfry-1(anddraco/fornax, which runkosmos_strfry::nginx).Acceptance
REQ {"kinds":[1059],"#p":["<user>"]}.p-tagged giftwraps.strfry: enable NIP-17 inbox relay (read-auth for kind 1059) once strfry release includes PR #250to Enable NIP-17 inbox relay (read-auth for kind 1059) after next strfry releaseEnable NIP-17 inbox relay (read-auth for kind 1059) after next strfry releaseto Enable NIP-17 inbox relay after next strfry releaseRefined spec — write policy (ldap-policy.ts) for NIP-17 inbox relay
Capturing the finalized plan for the
akkountswrite-policy side, to execute as part of the coordinated deploy in this issue once the strfry read-auth release is live.File
akkounts/extras/strfry/ldap-policy.ts(only file changing; nostrfry-policy.ts,deno.json, ordeno.lockchanges — no new deps).Change
Add a branch immediately after the existing
9735(zap receipt) block, mirroring its "overridepubkeyto the relevant key, then fall through to the LDAP search" pattern. Covers both giftwrap kinds:Falls through to the existing
(nostrKey=${pubkey})search →memberKey === pubkeycheck, so the giftwrap is accepted iff the recipient (firstp-tag) is a Kosmos user.nostrKeyis effectively single-valued per user (LdapManager::UpdateNostrKeyusesreplace_attributewith one value), so the single-entry match works for the recipient unchanged.Verification
No runtime test (needs live LDAP); the 1059/21059 branch is pure logic over
tags, type-checked against@nostrify/types.PR & deploy (coordinated with strfry read-auth — DO NOT merge first)
Privacy-regression window: today 1059 is rejected (random author ∉ LDAP → nothing stored). Merging this write-policy change alone would store giftwraps on strfry 1.1.1, which has no read-side policy → anyone could
REQ {"kinds":[1059],"#p":["…"]}and read them (ciphertext + recipient metadata). Worse than today.Deploy order — strict:
strfry-1/draco/fornax(chef side of this issue).strfry/inbox-giftwrap-policyoffmaster→ PR targetmaster→ merge →master→live.site-cookbooks/kosmos_strfry/recipes/policies.rbre-fetches the new script.Consistency note
The write gate (recipient == first
p-tag) matches the read gate from upstream PR #250 (ReadRestrictor::shouldSendToSubscriberchecks the firstp-tag == authed subscriber), so write and read agree on who "the recipient" is.Scope decisions
1059and21059accepted (ephemeral 21059 not persisted by strfry, but its live delivery is gated by read-auth once enabled).