feat: NIP-42: Implement AUTH Challenge-Response Flow#571
Open
alibaba0010 wants to merge 1 commit intocameri:mainfrom
Open
feat: NIP-42: Implement AUTH Challenge-Response Flow#571alibaba0010 wants to merge 1 commit intocameri:mainfrom
alibaba0010 wants to merge 1 commit intocameri:mainfrom
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request implements NIP-42 (Authentication of clients to relays) in Nostream. This allows the relay to verify the identity of clients via a challenge-response mechanism using Nostr events (Kind 22242).
Key changes include:
AUTHtoMessageTypeandEventKinds(Kind 22242).WebSocketAdapterto generate and store a unique 16-byte hex challenge for every client session upon connection.AuthMessageHandlerwhich performs a full cryptographic and protocol validation of incomingAUTHevents, including:relay_url.messageHandlerFactorywith proper dependency injection of settings.message-schema.tsto support incomingAUTHmessages.Related Issue
Linked to the Nostream competency assessment for NIP implementation.
Motivation and Context
NIP-42 is a core Nostr improvement that enables relays to authenticate users, which is essential for access control, paid relay features, and spam mitigation. This implementation brings Nostream closer to full NIP compliance.
How Has This Been Tested?
test/unit/adapters/web-socket-adapter.spec.tscaused by the immediate challenge dispatch. Verified that the full test suite (1,046 tests) passes.task3.js) that connects to the relay, parses the challenge, signs a valid response, and submits it.task4.tsandtest_task4.tsto independently verify the Schnorr signature logic using@noble/secp256k1.Screenshots (if appropriate):
N/A (Backend logic)
Types of changes
Checklist: