Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
89b19aa
docs: add comprehensive PR for all changes from 0.2.2 to 0.5.1
Oct 5, 2025
76bd6cb
style: fix Qodana findings (javadoc order, regex, redundant cast, com…
Oct 6, 2025
d69c0c5
refactor: address additional Qodana issues (duplicate expressions, re…
Oct 6, 2025
c22e564
style: suppress unchecked warnings and remove redundant casts across …
Oct 6, 2025
edac1fd
chore: restore workflow, qodana config, and docs removed inadvertently
Oct 6, 2025
cc1a5d3
refactor: use typed tag helpers across API and events; add code-aware…
Oct 6, 2025
520d866
Merge remote-tracking branch 'origin/develop' into develop
Oct 6, 2025
bed8994
Merge remote-tracking branch 'origin/develop' into chore/qodana-fixes
Oct 6, 2025
68114ed
chore(bom): bump to 1.1.1 and remove local JUnit overrides; test: qua…
Oct 6, 2025
e198b6e
chore(version): bump project version to 0.6.0 across poms and docs
Oct 6, 2025
6146268
Merge pull request #453 from tcheeric/chore/qodana-fixes
tcheeric Oct 6, 2025
98df86e
Merge remote-tracking branch 'origin/develop' into develop
Oct 6, 2025
6e1ee6a
fix(logging): improve error messages and log levels per Clean Code gu…
Oct 6, 2025
911ab87
refactor(logging): remove constructor logging from low-level key classes
Oct 6, 2025
33270a7
refactor(test): remove test method name logging per Clean Code guidel…
Oct 6, 2025
337bce4
refactor(logging): extract duplicated recovery logging in SpringWebSo…
Oct 6, 2025
90a4c8b
chore: bump version to 0.6.1
Oct 6, 2025
1feba9f
Merge pull request #454 from tcheeric/chore/bump-version-0.6.1
tcheeric Oct 6, 2025
a988d62
fix(logging): improve error messages and log levels per Clean Code gu…
Oct 6, 2025
5ffd3e7
refactor(logging): remove constructor logging from low-level key classes
Oct 6, 2025
37ea04b
refactor(test): remove test method name logging per Clean Code guidel…
Oct 6, 2025
6326f23
refactor(logging): extract duplicated recovery logging in SpringWebSo…
Oct 6, 2025
e813346
Merge remote-tracking branch 'origin/develop' into develop
Oct 6, 2025
c0e6509
docs(javadoc): fix plain-text NIP links to anchors; fully-qualify Jav…
Oct 6, 2025
7dc0019
docs(javadoc): address Qodana javadoc items (anchor NIP links, fully-…
Oct 6, 2025
f5ce0ad
chore: bump version to 0.6.2 and tighten fields per Qodana (FieldMayB…
Oct 6, 2025
93c5c2c
test: configure Mockito to use subclass mock-maker via SPI and surefi…
Oct 6, 2025
529b849
Merge pull request #455 from tcheeric/chore/qodana-final-and-bump-0.6.2
tcheeric Oct 6, 2025
7e9c139
fix: replace generic exception handling
tcheeric Oct 6, 2025
ec39a51
Merge pull request #456 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
9995e9f
fix: replace sneaky throws with explicit handling
tcheeric Oct 6, 2025
1a86ffb
Merge pull request #457 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
176020d
refactor: unify nostr exception hierarchy
tcheeric Oct 6, 2025
a555d0a
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
7816173
Merge pull request #458 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
981c57d
refactor: modularize nip helpers and client orchestration
tcheeric Oct 6, 2025
f11f80a
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
8ce884d
Merge pull request #459 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
241cbe2
refactor: streamline subscriptions and zap parameters
tcheeric Oct 6, 2025
5a52f53
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
e9a3248
Merge pull request #460 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
9397543
docs: clarify api documentation
tcheeric Oct 6, 2025
028d724
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
1c4ddf0
Merge pull request #461 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
b2abab2
refactor: normalize event cache naming and mapper access
tcheeric Oct 6, 2025
7ca269c
Merge branch 'develop' into codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
6c89350
Merge pull request #462 from tcheeric/codex/create-tasks-for-milestone-1
tcheeric Oct 6, 2025
67a565a
fix(api): allow optional sender when constructing websocket client
tcheeric Oct 6, 2025
398fc69
Merge pull request #463 from tcheeric/codex/fix-ci-error
tcheeric Oct 6, 2025
e2c80fc
refactor: abstract relay clients and codify nip ranges
tcheeric Oct 6, 2025
d3499a1
Merge branch 'develop' into codex/create-tasks-for-milestone-1-ylzf9j
tcheeric Oct 6, 2025
9ee96ee
Merge pull request #464 from tcheeric/codex/create-tasks-for-mileston…
tcheeric Oct 6, 2025
6b2a597
feat: finalize calendar decoding and generic event builder
tcheeric Oct 6, 2025
175b159
Merge branch 'develop' into codex/create-tasks-for-milestone-1-mt6702
tcheeric Oct 6, 2025
afdb80a
Merge pull request #465 from tcheeric/codex/create-tasks-for-mileston…
tcheeric Oct 6, 2025
69fefe1
build(pom): restore BOM version to 1.1.1 and re-add internal module o…
Oct 6, 2025
00c2ab5
chore(deps): bump org.sonatype.central:central-publishing-maven-plugin
dependabot[bot] Oct 6, 2025
7b71243
docs: complete Phase 2 documentation enhancement
Oct 6, 2025
223d911
Merge pull request #467 from tcheeric/docs/phase-2-documentation-enha…
tcheeric Oct 6, 2025
8216182
Merge pull request #466 from tcheeric/dependabot/maven/develop/org.so…
tcheeric Oct 6, 2025
0925bbd
docs: complete Phase 2 Task 5 - extended JavaDoc for NIPs and exceptions
Oct 6, 2025
2844e5e
chore: organize project management files into .project-management folder
Oct 6, 2025
6635cc4
chore: rename logging review and improvements markdown files
Oct 6, 2025
cfac008
Merge pull request #468 from tcheeric/docs/phase-2-extended-javadoc
tcheeric Oct 6, 2025
4ed2daf
docs: add MIGRATION.md for 1.0.0 upgrade path - Phase 2 Task 6 complete
Oct 8, 2025
89c05b0
test: add comprehensive tests for NIP-04, NIP-44, and NIP-57
Oct 8, 2025
afb5ffa
docs: add Phase 3 & 4 testing analysis and progress tracking
Oct 8, 2025
482fff9
chore: bump version to 0.6.4
Oct 8, 2025
e215449
docs: add PR document for critical tests and Phase 3 & 4
Oct 8, 2025
b963138
fix: remove unsupported eventId test from NIP57ImplTest
Oct 8, 2025
d191718
fix: adjust NIP-44 tests to respect NIP-44 plaintext constraints
Oct 8, 2025
cf5fc5b
Merge pull request #470 from tcheeric/test/critical-nip-tests-impleme…
tcheeric Oct 8, 2025
4bcc23b
chore(tests): strengthen client/handler tests and increase coverage; …
Oct 9, 2025
d5a3c60
Merge pull request #471 from tcheeric/chore/tests-coverage-enhancements
tcheeric Oct 9, 2025
a199549
build(api): add slf4j-test version (2.4.0) for test logging assertions
Oct 9, 2025
e98c4ce
chore: automate roadmap project setup
tcheeric Oct 11, 2025
6d653b0
Merge pull request #472 from tcheeric/codex/establish-remaining-tasks…
tcheeric Oct 11, 2025
e2f0382
Merge remote-tracking branch 'origin/develop' into develop
Oct 11, 2025
31ce804
fix(api): close WebSocket clients when subscription handles close; bu…
Oct 11, 2025
471c290
Merge pull request #473 from tcheeric/fix/websocket-handler-close-client
tcheeric Oct 11, 2025
fa6a8ba
chore: bump project version to 1.0.0-SNAPSHOT
Oct 11, 2025
5cd2a91
docs(migration): update migration steps for nostr-java BOM usage
Oct 11, 2025
85985de
docs(troubleshooting): update dependency version references for clarity
Oct 11, 2025
4243e5a
fix: parse BOLT11 separator correctly
tcheeric Oct 11, 2025
4d63f19
test: fix bolt11 whole btc fixture
tcheeric Oct 11, 2025
6fd28ca
Merge pull request #475 from tcheeric/codex/address-review-comment-in…
tcheeric Oct 11, 2025
7679bf2
fix(bolt11): correct HRP separator parsing in BOLT11 invoices
Oct 11, 2025
d4ddb67
fix(nip01): handle null uuid in identifier tag parsing
Oct 11, 2025
9861b76
feat: enhance task management in roadmap project script
Oct 11, 2025
de0f48a
Merge pull request #474 from tcheeric/chore/bump-version-1.0.0-SNAPSHOT
tcheeric Oct 11, 2025
199764f
chore(version): bump to 1.0.1-SNAPSHOT across all modules
Oct 12, 2025
4274095
fix: restore GenericTag fallback for DM decrypt
tcheeric Oct 12, 2025
b85dd49
Merge pull request #476 from tcheeric/chore/bump-version-1.0.1-SNAPSHOT
tcheeric Oct 12, 2025
8d04481
refactor(tags): reorganize imports for clarity
Oct 12, 2025
2d3cbd4
docs: rename relay references to 398ja
tcheeric Oct 12, 2025
8857498
Merge pull request #477 from tcheeric/codex/update-relay-name-from-da…
tcheeric Oct 12, 2025
41cdc37
fix: enforce string nip metadata
tcheeric Oct 12, 2025
4df2582
Merge pull request #478 from tcheeric/codex/update-event-kind-type-to…
tcheeric Oct 12, 2025
98d4df3
chore(deps): bump actions/checkout from 4 to 5
dependabot[bot] Oct 13, 2025
7c3458f
chore(deps): bump actions/setup-java from 4 to 5
dependabot[bot] Oct 13, 2025
ac61230
chore(deps): bump org.jacoco:jacoco-maven-plugin from 0.8.13 to 0.8.14
dependabot[bot] Oct 13, 2025
364452b
Merge pull request #481 from tcheeric/dependabot/maven/develop/org.ja…
tcheeric Oct 13, 2025
c8518be
Merge pull request #479 from tcheeric/dependabot/github_actions/devel…
tcheeric Oct 13, 2025
5834f52
Merge pull request #480 from tcheeric/dependabot/github_actions/devel…
tcheeric Oct 13, 2025
4a340ab
chore(version): bump to 1.0.2-SNAPSHOT across all modules
Oct 13, 2025
796773c
chore: release version 1.0.0
Oct 13, 2025
993b342
refactor(api): remove deprecated Identity parameter methods from NIP01
Oct 13, 2025
21c704a
Merge pull request #482 from tcheeric/chore/bump-version-1.0.2-SNAPSHOT
tcheeric Oct 13, 2025
d35c334
docs(readme): update troubleshooting section and remove outdated content
Oct 13, 2025
5af42bd
docs(readme): fix formatting of features list for consistency
Oct 13, 2025
0dcd0dc
chore: update changelog for version 1.0.0 release
Oct 13, 2025
8fbbb71
refactor(api)!: clean up and remove deprecated APIs in v1.0.0
Oct 13, 2025
9726c58
refactor(release): enhance Maven command options handling
Oct 13, 2025
baa075b
chore(settings): add Maven settings for repository configuration
Oct 13, 2025
7e273ec
chore(settings): update Maven repository URL for consistency
Oct 14, 2025
6cefd8f
fix(api): handle generic p-tags during DM decrypt
tcheeric Oct 14, 2025
54109ad
Merge pull request #484 from tcheeric/codex/add-unit-test-for-nip04.java
tcheeric Oct 14, 2025
c966937
fix: restore sender overrides in NIP-01 builder
tcheeric Oct 14, 2025
00870ac
style: use diamond operator in NIP01 builder
tcheeric Oct 14, 2025
b0b8d60
Merge pull request #485 from tcheeric/codex/address-code-comment-in-n…
tcheeric Oct 14, 2025
38b1639
Merge branch 'chore/bump-version-1.0.2-SNAPSHOT' into codex/address-c…
tcheeric Oct 14, 2025
042d019
Merge pull request #486 from tcheeric/codex/address-code-comment-in-n…
tcheeric Oct 14, 2025
c652345
Merge pull request #487 from tcheeric/chore/bump-version-1.0.2-SNAPSHOT
tcheeric Oct 14, 2025
58bceed
refactor(api)!: simplify event building methods by removing sender pa…
Oct 14, 2025
3a16764
refactor(api): update default sender handling in NIP01 event builder
Oct 14, 2025
7c90fec
ci: update Maven command to use custom settings file
Oct 14, 2025
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
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/EventNostr.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import java.util.List;
Expand All @@ -28,7 +24,7 @@

@Setter private GenericEvent event;

private PublicKey recipient;

Check warning on line 27 in nostr-java-api/src/main/java/nostr/api/EventNostr.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Field can be local variable

Field can be converted to a local variable

public EventNostr(@NonNull Identity sender) {
super(sender);
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP02.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import java.util.List;
Expand Down Expand Up @@ -32,7 +28,7 @@
@SuppressWarnings("rawtypes")
public NIP02 createContactListEvent(List<BaseTag> pubKeyTags) {
GenericEvent genericEvent =
new GenericEventFactory(getSender(), Constants.Kind.CONTACT_LIST, pubKeyTags, "").create();

Check warning on line 31 in nostr-java-api/src/main/java/nostr/api/NIP02.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unchecked warning

Unchecked call to 'GenericEventFactory(Identity, Integer, List, String)' as a member of raw type 'nostr.api.factory.impl.GenericEventFactory'
updateEvent(genericEvent);
return this;
}
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP03.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import lombok.NonNull;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP04.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import java.util.List;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP05.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import static nostr.base.IEvent.MAPPER_BLACKBIRD;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP12.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import java.net.URL;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP14.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import java.util.List;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP15.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import java.util.List;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP20.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import lombok.NonNull;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP23.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import java.net.URL;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP25.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import java.net.MalformedURLException;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP28.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import static nostr.api.NIP12.createHashtagTag;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP30.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import lombok.NonNull;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP32.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import lombok.NonNull;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP40.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import lombok.NonNull;
Expand Down
4 changes: 0 additions & 4 deletions nostr-java-api/src/main/java/nostr/api/NIP42.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@ public final class NostrEventDispatcher {
private final NoteService noteService;
private final NostrRelayRegistry relayRegistry;

/**
* Create a dispatcher that uses the provided services to verify and distribute events.
*
* @param noteService service responsible for communicating with relays
* @param relayRegistry registry that tracks the connected relay handlers
*/
public NostrEventDispatcher(NoteService noteService, NostrRelayRegistry relayRegistry) {
this.noteService = noteService;
this.relayRegistry = relayRegistry;
}

/**
* Verify the supplied event and forward it to all configured relays.
*
* @param event event to send
* @return responses returned by relays
* @throws IllegalStateException if verification fails
*/
public List<String> send(@NonNull IEvent event) {
if (event instanceof GenericEvent genericEvent) {
if (!verify(genericEvent)) {
Expand All @@ -32,6 +45,13 @@ public List<String> send(@NonNull IEvent event) {
return noteService.send(event, relayRegistry.getClientMap());
}

/**
* Verify the Schnorr signature of the provided event.
*
* @param event event to verify
* @return {@code true} if the signature is valid
* @throws IllegalStateException if the event is unsigned or verification cannot complete
*/
public boolean verify(@NonNull GenericEvent event) {
if (!event.isSigned()) {
throw new IllegalStateException("The event is not signed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,29 @@ public final class NostrRelayRegistry {
private final Map<String, WebSocketClientHandler> clientMap = new ConcurrentHashMap<>();
private final WebSocketClientHandlerFactory factory;

/**
* Create a registry backed by the supplied handler factory.
*
* @param factory factory used to lazily create relay handlers
*/
public NostrRelayRegistry(WebSocketClientHandlerFactory factory) {
this.factory = factory;
}

/**
* Expose the internal handler map for read-only scenarios.
*
* @return relay name to handler map
*/
public Map<String, WebSocketClientHandler> getClientMap() {
return clientMap;
}

/**
* Ensure handlers exist for the provided relay definitions.
*
* @param relays mapping of relay names to relay URIs
*/
public void registerRelays(Map<String, String> relays) {
for (Entry<String, String> relayEntry : relays.entrySet()) {
clientMap.computeIfAbsent(
Expand All @@ -34,6 +49,11 @@ public void registerRelays(Map<String, String> relays) {
}
}

/**
* Take a snapshot of the currently registered relay URIs.
*
* @return immutable copy of relay name to URI mappings
*/
public Map<String, String> snapshotRelays() {
return clientMap.values().stream()
.collect(
Expand All @@ -44,20 +64,36 @@ public Map<String, String> snapshotRelays() {
HashMap::new));
}

/**
* Return handlers that correspond to base relay connections (non request-scoped).
*
* @return list of base handlers
*/
public List<WebSocketClientHandler> baseHandlers() {
return clientMap.entrySet().stream()
.filter(entry -> !entry.getKey().contains(":"))
.map(Entry::getValue)
.toList();
}

/**
* Retrieve handlers dedicated to the provided subscription identifier.
*
* @param subscriptionId subscription identifier suffix
* @return list of handlers for the subscription
*/
public List<WebSocketClientHandler> requestHandlers(String subscriptionId) {
return clientMap.entrySet().stream()
.filter(entry -> entry.getKey().endsWith(":" + subscriptionId))
.map(Entry::getValue)
.toList();
}

/**
* Create request-scoped handlers for each base relay if they do not already exist.
*
* @param subscriptionId subscription identifier used to scope handlers
*/
public void ensureRequestClients(String subscriptionId) {
for (WebSocketClientHandler baseHandler : baseHandlers()) {
String requestKey = baseHandler.getRelayName() + ":" + subscriptionId;
Expand All @@ -67,6 +103,11 @@ public void ensureRequestClients(String subscriptionId) {
}
}

/**
* Close all handlers currently registered with the registry.
*
* @throws IOException if closing any handler fails
*/
public void closeAll() throws IOException {
for (WebSocketClientHandler client : clientMap.values()) {
client.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,22 @@ public final class NostrRequestDispatcher {

private final NostrRelayRegistry relayRegistry;

/**
* Create a dispatcher that leverages the registry to route REQ commands.
*
* @param relayRegistry registry that owns relay handlers
*/
public NostrRequestDispatcher(NostrRelayRegistry relayRegistry) {
this.relayRegistry = relayRegistry;
}

/**
* Send a REQ message using the provided filters across all registered relays.
*
* @param filters filters describing the subscription
* @param subscriptionId subscription identifier applied to handlers
* @return list of relay responses
*/
public List<String> sendRequest(@NonNull Filters filters, @NonNull String subscriptionId) {
relayRegistry.ensureRequestClients(subscriptionId);
return relayRegistry.requestHandlers(subscriptionId).stream()
Expand All @@ -26,6 +38,13 @@ public List<String> sendRequest(@NonNull Filters filters, @NonNull String subscr
.toList();
}

/**
* Send REQ messages for multiple filter sets under the same subscription identifier.
*
* @param filtersList list of filter definitions to send
* @param subscriptionId subscription identifier applied to handlers
* @return distinct collection of relay responses
*/
public List<String> sendRequest(@NonNull List<Filters> filtersList, @NonNull String subscriptionId) {
return filtersList.stream()
.map(filters -> sendRequest(filters, subscriptionId))
Expand All @@ -34,6 +53,15 @@ public List<String> sendRequest(@NonNull List<Filters> filtersList, @NonNull Str
.toList();
}

/**
* Convenience helper for issuing a REQ message via a specific client instance.
*
* @param client relay client used to send the REQ
* @param filters filters describing the subscription
* @param subscriptionId subscription identifier applied to the message
* @return list of responses returned by the relay
* @throws IOException if sending fails
*/
public static List<String> sendRequest(
@NonNull SpringWebSocketClient client,
@NonNull Filters filters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,24 @@ public final class NostrSubscriptionManager {

private final NostrRelayRegistry relayRegistry;

/**
* Create a manager backed by the provided relay registry.
*
* @param relayRegistry registry used to look up relay handlers
*/
public NostrSubscriptionManager(NostrRelayRegistry relayRegistry) {
this.relayRegistry = relayRegistry;
}

/**
* Subscribe to the provided filters across all base relay handlers.
*
* @param filters subscription filters to apply
* @param subscriptionId identifier shared across relay subscriptions
* @param listener callback invoked for each event payload
* @param errorConsumer callback invoked when an error occurs
* @return a handle that closes all subscriptions when invoked
*/
public AutoCloseable subscribe(
@NonNull Filters filters,
@NonNull String subscriptionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
*/
@FunctionalInterface
public interface WebSocketClientHandlerFactory {
/**
* Create a handler for the given relay definition.
*
* @param relayName logical relay identifier
* @param relayUri websocket URI of the relay
* @return initialized handler ready for use
* @throws ExecutionException if the underlying client initialization fails
* @throws InterruptedException if thread interruption occurs during initialization
*/
WebSocketClientHandler create(String relayName, String relayUri)
throws ExecutionException, InterruptedException;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api.factory;

import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api.factory;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api.factory;

import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package nostr.api.factory.impl;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -17,7 +13,7 @@
import nostr.event.json.codec.EventEncodingException;

/**
* Utility to create {@link BaseTag} instances from code and parameters or from JSON.

Check warning on line 16 in nostr-java-api/src/main/java/nostr/api/factory/impl/BaseTagFactory.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Declaration has problems in Javadoc references

Cannot resolve symbol `BaseTag`
*/
@Data
@EqualsAndHashCode(callSuper = false)
Expand Down Expand Up @@ -53,6 +49,15 @@
this.params = new ArrayList<>();
}

/**
* Build the tag instance based on the factory configuration.
*
* <p>If a JSON payload was supplied, it is decoded into a {@link GenericTag}. Otherwise, a tag

Check warning on line 55 in nostr-java-api/src/main/java/nostr/api/factory/impl/BaseTagFactory.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Declaration has problems in Javadoc references

Cannot resolve symbol `GenericTag`
* is built from the configured code and parameters.
*
* @return the constructed tag instance
* @throws EventEncodingException if the JSON payload cannot be parsed

Check warning on line 59 in nostr-java-api/src/main/java/nostr/api/factory/impl/BaseTagFactory.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Declaration has problems in Javadoc references

Cannot resolve symbol `EventEncodingException`
*/
public BaseTag create() {
if (jsonString != null) {
try {
Expand Down
Loading