Skip to content

feat(nip42): add session tracking and optional authRequired - #716

Merged
Anshumancanrock merged 8 commits into
cameri:mainfrom
Anshumancanrock:feat/nip42-session
Aug 20, 2026
Merged

feat(nip42): add session tracking and optional authRequired#716
Anshumancanrock merged 8 commits into
cameri:mainfrom
Anshumancanrock:feat/nip42-session

Conversation

@Anshumancanrock

Copy link
Copy Markdown
Collaborator

Summary

This PR tightens NIP-42 session handling without changing default relay behavior.

  • Track authenticated pubkeys in a proper per-socket session (with optional sessionTtl)
  • Add nip42.authRequired so relays can require AUTH before publishes
  • Advertise that correctly in NIP-11 (limitation.auth_required)

Defaults stay off (authRequired: false, sessionTtl: 0), so existing open relays behave the same.

@changeset-bot

changeset-botBot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bbbe4ec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
nostreamMinor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls

coveralls commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage is 70.993%Anshumancanrock:feat/nip42-session into cameri:main. No base build found for cameri:main.

@cameri
cameri requested a balanced review from CopilotAugust 12, 2026 02:10

CopilotAI 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.

Pull request overview

Adds per-socket NIP-42 session tracking, optional session expiry, and configurable publish authentication.

Changes:

  • Introduces Nip42SessionManager with TTL support.
  • Enforces optional authentication for event publishing.
  • Updates NIP-11 metadata, configuration, documentation, and tests.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
.changeset/nip42-session-manager.mdRecords the minor feature release.
CONFIGURATION.mdDocuments the new NIP-42 settings.
resources/default-settings.yamlAdds disabled-by-default configuration.
src/@types/settings.tsTypes the new settings.
src/adapters/web-socket-adapter.tsIntegrates per-socket sessions and expiry.
src/handlers/event-message-handler.tsEnforces publish authentication.
src/handlers/request-handlers/root-request-handler.tsAdvertises authentication in NIP-11.
src/routes/index.tsAdds CodeQL annotations for public routes.
src/utils/nip42-session.tsImplements session and challenge management.
src/utils/nip42.tsAdds the authentication-setting helper.
test/unit/adapters/web-socket-adapter.spec.tsTests adapter session behavior.
test/unit/handlers/event-message-handler.spec.tsTests publish-auth decisions.
test/unit/handlers/request-handlers/root-request-handler.spec.tsTests NIP-11 metadata.
test/unit/utils/nip42-session.spec.tsTests session management and expiry.
test/unit/utils/nip42.spec.tsTests authentication configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment threadsrc/handlers/request-handlers/root-request-handler.ts Outdated
Comment threadtest/unit/adapters/web-socket-adapter.spec.ts Outdated
Comment threadsrc/adapters/web-socket-adapter.ts Outdated
Comment threadresources/default-settings.yaml Outdated
@Anshumancanrock
Anshumancanrock merged commit 2f5a1c0 into cameri:mainAug 20, 2026
18 checks passed
Sign up for freeto 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.

4 participants

@Anshumancanrock@coveralls@cameri