Skip to content

feat: add NIP-43 invite code foundation#650

Open
Anshumancanrock wants to merge 1 commit into
mainfrom
feat/nip43-invite-codes
Open

feat: add NIP-43 invite code foundation#650
Anshumancanrock wants to merge 1 commit into
mainfrom
feat/nip43-invite-codes

Conversation

@Anshumancanrock

Copy link
Copy Markdown
Collaborator

Description

Invite code infrastructure for NIP-43 relay membership.

claimCode() uses a single atomic UPDATE with WHERE guards (not expired, uses remaining) so concurrent claims on the same code are safe without transactions.

claimed_by has no FK to users so users don't exist yet at claim time.

Related Issue

NIP-43 implementation

Motivation and Context

Need a data layer for NIP-43 join/leave handlers.

How Has This Been Tested?

25 unit tests, full suite 1322 passing.

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.

@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1c4b970

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 force-pushed the feat/nip43-invite-codes branch 2 times, most recently from 930a226 to afbfc55 Compare June 23, 2026 19:27
- Add event kinds 8000, 8001, 13534, 28934, 28935, 28936 and tags (member, claim)
- Create InviteCode/DBInviteCode types and Nip43Settings interface
- Add IInviteCodeRepository interface with create, findByCode, claimCode, findActiveCodes, deleteExpiredCodes
- Implement InviteCodeRepository with atomic claimCode via single UPDATE
- Add generateInviteCode() using crypto.randomBytes (128-bit entropy)
- Create invite_codes migration with CHECK constraints and partial index
- Add revokeAdmission() and findAllAdmitted() to UserRepository
- Add 27 unit tests with full coverage
@Anshumancanrock Anshumancanrock force-pushed the feat/nip43-invite-codes branch from afbfc55 to 1c4b970 Compare June 23, 2026 19:32
@coveralls

coveralls commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage is 67.056%feat/nip43-invite-codes into main. No base build found for 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