Skip to content

Feat/nip37 private storage relays#644

Open
nogringo wants to merge 2 commits into
masterfrom
feat/nip37-private-storage-relays
Open

Feat/nip37 private storage relays#644
nogringo wants to merge 2 commits into
masterfrom
feat/nip37-private-storage-relays

Conversation

@nogringo

@nogringo nogringo commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

This pr only add a high level api to get the private relays list

Summary by CodeRabbit

Release Notes

  • New Features

    • Added ability for logged-in users to fetch their private storage relay list.
  • Documentation

    • Updated documentation to explain private storage relay functionality and usage.
  • Tests

    • Added test coverage for private storage relay retrieval.

@nogringo nogringo requested review from 1-leo and frnandu June 3, 2026 09:54
@nogringo nogringo self-assigned this Jun 3, 2026
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds support for NIP-37 private storage relays in the NDK package. A new getPrivateStorageRelays() method fetches and decrypts a logged-in user's encrypted relay list from kind 10013 events, leveraging existing cache, network, and NIP-44 decryption infrastructure. The entity, method, and exports are tested end-to-end and documented, alongside supporting formatting updates to signer implementations.

Changes

NIP-37 Private Storage Relays

Layer / File(s) Summary
NIP-37 Entity Definition
packages/ndk/lib/domain_layer/entities/nip_37.dart
Introduces Nip37 class with kPrivateStorageRelays constant (kind 10013) to identify private storage relay events.
Private Storage Relay Fetch Implementation
packages/ndk/lib/domain_layer/usecases/user_relay_lists/user_relay_lists.dart
Adds getPrivateStorageRelays() method: loads cached kind-10013 events, queries network if needed, decrypts content via NIP-44, extracts relay URLs from decrypted tags, and returns relay list or null on failure.
Public API Exports
packages/ndk/lib/entities.dart, packages/ndk/lib/ndk.dart
Exports Nip37 entity through public library surface so consumers can import and reference it.
Tests
packages/ndk/test/usecases/user_relay_lists/user_relay_lists_test.dart
Tests getPrivateStorageRelays() returning null when event is absent, and end-to-end encryption/decryption/extraction when cached event is present.
Documentation
doc/usecases/user-relay-lists.md
Documents private storage relays as an exposed use case, notes encryption requirement and logged-in signer dependency, and provides example usage.
Code Formatting and Cleanup
packages/bc_ur/lib/ur.dart, packages/ndk_flutter/lib/data_layer/repositories/signers/amber_event_signer.dart, packages/ndk_flutter/lib/widgets/login/nostr_connect_dialog_view.dart, packages/nip07_event_signer/lib/src/nip07_event_signer_stub.dart, packages/nip07_event_signer/lib/src/nip07_event_signer_web.dart
Reformats multi-line class declarations, constructor assertions, and argument lists to single-line syntax; adjusts request-cancellation guards for consistency across signer implementations.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant UserRelayLists
  participant Cache
  participant Network
  participant Signer
  Caller->>UserRelayLists: getPrivateStorageRelays(forceRefresh)
  UserRelayLists->>Cache: load Nip37.kPrivateStorageRelays events
  alt forceRefresh or no cached event
    UserRelayLists->>Network: query latest kind 10013 event
    Network-->>UserRelayLists: event or null
  end
  alt event found
    UserRelayLists->>Cache: save latest event
    UserRelayLists->>Signer: decryptNip44(eventContent)
    Signer-->>UserRelayLists: decrypted JSON
    UserRelayLists->>UserRelayLists: parse tags, extract relay URLs
    UserRelayLists-->>Caller: List<String> relay URLs
  else no event or decryption failed
    UserRelayLists-->>Caller: null
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • relaystr/ndk#608: Both PRs add relay-list fetch methods to UserRelayLists that load cached kind-specific events and extract relay URLs from tags (this PR: NIP-37 kind 10013, related PR: NIP-17 kind 10050).

Suggested labels

enhancement

Suggested reviewers

  • frnandu
  • 1-leo

Poem

🐰 A rabbit hops through relays encrypted,
Decrypting kind 10013 with NIP-44 grip,
Cache-first and network-smart together,
Private storage relays bloom forever! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat/nip37 private storage relays' accurately describes the main change: adding NIP-37 private storage relay support with a new getPrivateStorageRelays() method.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/nip37-private-storage-relays

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@doc/usecases/user-relay-lists.md`:
- Line 13: The document contains the nonstandard term "usecase" (e.g., the
sentence "NIP-37 private storage relays are exposed through the same usecase.");
update occurrences of the token "usecase" to the standard spelling "use case"
throughout the file (for example edit the sentence to "NIP-37 private storage
relays are exposed through the same use case").
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 00e20e89-514e-4f8d-96cb-f4dd69f67d34

📥 Commits

Reviewing files that changed from the base of the PR and between e8648bf and 25c7e3d.

📒 Files selected for processing (11)
  • doc/usecases/user-relay-lists.md
  • packages/bc_ur/lib/ur.dart
  • packages/ndk/lib/domain_layer/entities/nip_37.dart
  • packages/ndk/lib/domain_layer/usecases/user_relay_lists/user_relay_lists.dart
  • packages/ndk/lib/entities.dart
  • packages/ndk/lib/ndk.dart
  • packages/ndk/test/usecases/user_relay_lists/user_relay_lists_test.dart
  • packages/ndk_flutter/lib/data_layer/repositories/signers/amber_event_signer.dart
  • packages/ndk_flutter/lib/widgets/login/nostr_connect_dialog_view.dart
  • packages/nip07_event_signer/lib/src/nip07_event_signer_stub.dart
  • packages/nip07_event_signer/lib/src/nip07_event_signer_web.dart


## Private storage relays

NIP-37 private storage relays are exposed through the same usecase.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use standard spelling: “use case”.

Replace “usecase” with “use case” to match common terminology and improve documentation readability.

🧰 Tools
🪛 LanguageTool

[grammar] ~13-~13: Ensure spelling is correct
Context: ...age relays are exposed through the same usecase. The kind 10013 event is encrypted, s...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@doc/usecases/user-relay-lists.md` at line 13, The document contains the
nonstandard term "usecase" (e.g., the sentence "NIP-37 private storage relays
are exposed through the same usecase."); update occurrences of the token
"usecase" to the standard spelling "use case" throughout the file (for example
edit the sentence to "NIP-37 private storage relays are exposed through the same
use case").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant