feat(nip42): add session tracking and optional authRequired - #716
Conversation
🦋 Changeset detectedLatest commit: bbbe4ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
4be9d12 to
b0c8ad0CompareThere was a problem hiding this comment.
Pull request overview
Adds per-socket NIP-42 session tracking, optional session expiry, and configurable publish authentication.
Changes:
- Introduces
Nip42SessionManagerwith 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
| File | Description |
|---|---|
.changeset/nip42-session-manager.md | Records the minor feature release. |
CONFIGURATION.md | Documents the new NIP-42 settings. |
resources/default-settings.yaml | Adds disabled-by-default configuration. |
src/@types/settings.ts | Types the new settings. |
src/adapters/web-socket-adapter.ts | Integrates per-socket sessions and expiry. |
src/handlers/event-message-handler.ts | Enforces publish authentication. |
src/handlers/request-handlers/root-request-handler.ts | Advertises authentication in NIP-11. |
src/routes/index.ts | Adds CodeQL annotations for public routes. |
src/utils/nip42-session.ts | Implements session and challenge management. |
src/utils/nip42.ts | Adds the authentication-setting helper. |
test/unit/adapters/web-socket-adapter.spec.ts | Tests adapter session behavior. |
test/unit/handlers/event-message-handler.spec.ts | Tests publish-auth decisions. |
test/unit/handlers/request-handlers/root-request-handler.spec.ts | Tests NIP-11 metadata. |
test/unit/utils/nip42-session.spec.ts | Tests session management and expiry. |
test/unit/utils/nip42.spec.ts | Tests authentication configuration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
This PR tightens NIP-42 session handling without changing default relay behavior.
sessionTtl)nip42.authRequiredso relays can require AUTH before publisheslimitation.auth_required)Defaults stay off (
authRequired: false,sessionTtl: 0), so existing open relays behave the same.