Skip to content

feat(nip43): add join/leave request event strategies#676

Draft
Anshumancanrock wants to merge 1 commit into
cameri:mainfrom
Anshumancanrock:feat/nip43-join-leave
Draft

feat(nip43): add join/leave request event strategies#676
Anshumancanrock wants to merge 1 commit into
cameri:mainfrom
Anshumancanrock:feat/nip43-join-leave

Conversation

@Anshumancanrock

Copy link
Copy Markdown
Collaborator

Description

Adds event strategies for NIP-43 join (kind 28934) and leave (kind 28936) requests.

When a client sends a join request with an invite code, the relay validates NIP-42 auth, atomically claims the code, and admits the user. Leave requests revoke admission after verifying membership.

Also wires InviteCodeRepository through the factory chain, adds pipeline bypasses so join/leave events aren't blocked by admission or NIP-05 checks (since they are the admission flow), and advertises NIP-43 in the NIP-11 document.

Related Issue

Continuation of #650 (NIP-43 invite code foundation).

Motivation and Context

NIP-43 defines how relays handle membership-based access control. #650 laid the database layer and this PR adds the handler layer so the relay can actually process join/leave requests from clients.

How Has This Been Tested?

  • 11 new unit tests across both strategies covering: disabled NIP-43, unauthenticated requests, missing claim tags, duplicate members, invalid codes, successful join, non-member leave (no-op), and successful revocation.
  • Updated 3 factory test files to account for new parameters.

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

Wire InviteCodeRepository through the factory chain and add event
strategies for NIP-43 access request kinds:

- kind 28934 (Join Request): validates NIP-42 auth, extracts claim tag,
  atomically claims invite code, admits user
- kind 28936 (Leave Request): validates NIP-42 auth, checks membership,
  revokes admission

Pipeline changes:
- Route NIP-43 kinds before the ephemeral catch-all (prevents broadcast)
- Bypass isUserAdmitted for join/leave (they ARE the admission flow)
- Bypass checkNip05Verification for join/leave (new users have no record)
- Remove stale knip.json ignore for invite-code-repository

Includes unit tests for both strategies and updated factory tests.
@changeset-bot

changeset-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9c2ce97

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

This PR includes changesets to release 1 package
Name Type
nostream Minor

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

@Anshumancanrock Anshumancanrock marked this pull request as draft July 11, 2026 18:58
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 67.984% (+0.3%) from 67.674% — Anshumancanrock:feat/nip43-join-leave into cameri:main

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.

2 participants