Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ POSTGRES_PASSWORD_ENCODED=
NOSTR_PRIVATE_KEY=
# DEFAULT_RELAYS: comma-separated list of wss:// relay URLs. This value is public:
# it is sent to browsers and appears in generated RSS feeds. Never put credentials in it.
DEFAULT_RELAYS="wss://relay.damus.io,wss://nos.lol,wss://relay.nostr.band"
DEFAULT_RELAYS="wss://relay.damus.io,wss://nos.lol"

# Optional: overrides the admin npub. Defaults to the bundled admin npub when unset.
NEXT_PUBLIC_ADMIN_NPUB=
Expand Down
2 changes: 1 addition & 1 deletion .env.production.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NODE_ENV="production"
# Nostr Configuration
# DEFAULT_RELAYS: comma-separated list of wss:// relay URLs. This value is public:
# it is sent to browsers and appears in generated RSS feeds. Never put credentials in it.
DEFAULT_RELAYS="wss://relay.damus.io,wss://nos.lol,wss://relay.nostr.band,wss://relay.snort.social"
DEFAULT_RELAYS="wss://relay.damus.io,wss://nos.lol,wss://relay.snort.social"
NOSTR_BUNKER_URL=""

# Optional: overrides the admin npub. Defaults to the bundled admin npub when unset.
Expand Down
5 changes: 3 additions & 2 deletions desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ version replaces the older one in place, keeping its read and starred marks.
Give Readstr your npub (or an nprofile, whose relay hints are asked too)
with "Sync with Nostr…" in the `⋮` menu or `readstr sync login npub1…`, and
it pulls what the Readstr web app publishes for it: the subscription list
(kind 30404), the read articles (kind 30405, once the web app publishes it;
it does not yet), and the saved views (kind 30406). Only the public key is kept; nothing is ever signed or published,
(kind 30404), the read articles (kind 30405, which the web app publishes only
when its read-sync setting is on, and then only its most recent reads), and
the saved views (kind 30406). Only the public key is kept; nothing is ever signed or published,
which is why no signer is needed: the web app publishes these events in
cleartext, so anyone can read them. The window pulls right after you log in
and after every refresh of all feeds, so read marks find the articles it
Expand Down
4 changes: 1 addition & 3 deletions desktop/src/relaypool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,7 @@ RelayPool::~RelayPool() {
}

QStringList RelayPool::defaultRelays() {
// The web app's fallback relays, less relay.nostr.band and
// nostr-pub.wellorder.net, which no longer answer and would hold every
// refresh up until they time out.
// The web app's fallback relays.
return {QStringLiteral("wss://relay.damus.io"), QStringLiteral("wss://relay.primal.net"),
QStringLiteral("wss://nos.lol"), QStringLiteral("wss://relay.snort.social")};
}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
environment:
- NODE_ENV=production
- DATABASE_URL=postgresql://${POSTGRES_USER:-nostr_user}:${POSTGRES_PASSWORD_ENCODED:-${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}}@postgres:5432/${POSTGRES_DB:-readstr}
- DEFAULT_RELAYS=wss://relay.damus.io,wss://nos.lol,wss://relay.nostr.band
- DEFAULT_RELAYS=wss://relay.damus.io,wss://nos.lol
depends_on:
- postgres
restart: unless-stopped
Expand Down
2 changes: 0 additions & 2 deletions docs/CLI_DEVELOPMENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,6 @@ var DefaultRelays = []string{
"wss://relay.damus.io",
"wss://nos.lol",
"wss://relay.snort.social",
"wss://relay.nostr.band",
"wss://nostr-pub.wellorder.net",
}
```

Expand Down
33 changes: 30 additions & 3 deletions docs/SUBSCRIPTION_SYNC.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,35 @@ Read status for feed items is synced using kind `30405`:
- Syncs across all devices
- Uses item GUIDs for identification

How the web app handles it:

- **Opt-in.** It is off by default. The "Sync read articles across devices"
setting (localStorage `readstr_read_sync`) turns it on, and only signed-in
users who can sign take part.
- **Public.** The event is cleartext, so anyone can see which articles the
user read. Turning the setting off publishes an empty replacement list, best
effort; relays and other clients may keep older copies.
- **Capped.** Common strfry relays refuse events over 64 KiB, so the web app
publishes only the newest reads that fit about 60,000 bytes of event JSON
(`MAX_PUBLISHED_READ_CONTENT`): its own reads from feeds the user still
subscribes to, newest first, then the guids of the last list it pulled that
no feed of its own has. It accepts pulled lists of up to 8 MiB and 100,000
guids of at most 256 UTF-16 units each, since other clients may publish
bigger ones.
- **Additive.** A pulled list only marks items read; a guid missing from it
never marks anything unread. The web app pulls once per session before it
publishes, and publishes only after a pull applied the newest list, found it
already applied, or found that no relay has one. "No relay has one" needs an
answer from every relay that connected, so a relay that connects and then
times out cannot lead to a replacement that drops another device's reads.
A relay that is down when this device pulls, and that alone holds another
device's newest list, can still be missed, so this is best effort.
- **Keys.** An item's key is its guid, trimmed, or its link when it has no
guid, as on the desktop. Stored guids are not trimmed, so a pulled key never
matches an item whose stored guid has leading or trailing whitespace. This
is a known, rare mismatch: trimming at ingest would change the identity of
existing items and create duplicates.

### Event Structure - Subscription List

```json
Expand Down Expand Up @@ -390,8 +419,6 @@ const SYNC_RELAYS = [
'wss://relay.damus.io',
'wss://nos.lol',
'wss://relay.snort.social',
'wss://relay.nostr.band',
'wss://nostr-pub.wellorder.net',
]
```

Expand Down Expand Up @@ -561,7 +588,7 @@ check();

### Manual Event Inspection

Use [nostr.band](https://nostr.band) or [njump.me](https://njump.me) to search for kind 30404 events.
Use [njump.me](https://njump.me) to search for kind 30404 events.

## Security Considerations

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- CreateIndex
CREATE INDEX "ReadItem_userPubkey_readAt_idx" ON "ReadItem"("userPubkey", "readAt");
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ model ReadItem {
@@unique([userPubkey, itemId])
@@index([userPubkey])
@@index([userPubkey, syncedAt])
@@index([userPubkey, readAt])
}

model Favorite {
Expand Down
2 changes: 0 additions & 2 deletions scripts/seed-guide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const DEFAULT_RELAYS = [
'wss://relay.damus.io',
'wss://nos.lol',
'wss://relay.snort.social',
'wss://relay.nostr.band',
'wss://nostr-pub.wellorder.net'
]

// Popular Nostr long-form content creators with relevant tags
Expand Down
13 changes: 1 addition & 12 deletions src/app/api/trpc/[trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ import { buildRequestContext, type RequestLike } from '@/server/auth/request-con
import { readBodyWithLimit, type ReadBodyResult } from '@/server/http/read-body'
import { countTrpcCalls } from '@/server/http/trpc-batch'
import { clientIpFromRequest, rateLimit } from '@/server/rate-limit'
import { MAX_TRPC_BATCH_SIZE } from '@/trpc/batch-limits'
import { MAX_TRPC_BATCH_SIZE, MAX_TRPC_BODY_BYTES } from '@/trpc/batch-limits'

const TRPC_ENDPOINT = '/api/trpc'

/**
* Largest tRPC request body accepted. Only mutations send a body; queries such
* as getFeedItems carry their input in the GET URL. The biggest real body is a
* batch of markAsRead calls (~45 bytes each, so ~1,400 fit); most calls are
* well under 1 KB. The cap keeps zod v3's per-element parsing of hostile arrays
* (~150x heap amplification, GHSA-mrhx-c7xc-m3w5) to roughly 10 MB per
* request, and runs before NIP-98 auth and any procedure's rate limit, so it
* also protects public mutations.
*/
const MAX_TRPC_BODY_BYTES = 64_000

/**
* Per-IP budget of procedure calls per minute, charged one unit per call in a
* batch so batching cannot dodge it. Normal use stays far below it: a page
Expand Down
Loading