Skip to content

feat: add a CLI to mint NIP-43 invite codes - #732

Merged
Anshumancanrock merged 3 commits into
cameri:mainfrom
Anshumancanrock:feat/nip43-invite-cli
Aug 16, 2026
Merged

feat: add a CLI to mint NIP-43 invite codes#732
Anshumancanrock merged 3 commits into
cameri:mainfrom
Anshumancanrock:feat/nip43-invite-cli

Conversation

@Anshumancanrock

@Anshumancanrock Anshumancanrock commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds nostream invite create so one can mint a NIP-43 claim without writing SQL.

nostream invite create
nostream invite create --uses 3 --expires-in 86400 --json

# Docker (Postgres isn't published on the host)
docker compose exec nostream node src/cli/index.js invite create

Defaults come from nip43.defaultMaxUses (1) and nip43.inviteCodeExpiry (0 = never). If info.self is hex or npub1…, it gets stored as created_by.

Related Issue

Follow-up to #676. Join (28934) is already on main; there was still no operator path to create a code.

Motivation and Context

Kind 28934 can claim a code, but minting one meant inserting into invite_codes by hand. That's not usable.

@changeset-bot

changeset-bot Bot commented Aug 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 47bae5e

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

@coveralls

coveralls commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 70.218% (+0.2%) from 70.024% — Anshumancanrock:feat/nip43-invite-cli into cameri:main

Comment thread resources/default-settings.yaml Outdated

Copilot AI 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 an operator-facing CLI workflow for minting NIP-43 invite codes (kind 28934 claim strings) without manual SQL, wiring it into the existing invite-code persistence layer and documenting the feature.

Changes:

  • Adds nostream invite create CLI command (with JSON output and DB connectivity hints) to mint invite codes.
  • Introduces shared NIP-43 invite helpers (generateInviteCode, settings-derived defaults, pubkey parsing) and expands repository support to persist created_by.
  • Updates defaults/config docs plus adds unit/integration tests to keep CLI/docs/settings aligned.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/unit/utils/settings.spec.ts Verifies nip43 defaults exist in default-settings.yaml and merge correctly.
test/unit/utils/nip43-invites.spec.ts Adds unit tests for new invite helper utilities (code generation, limits, pubkey parsing, issuing).
test/unit/repositories/invite-code-repository.spec.ts Updates repository tests for new create(code, options) signature and created_by persistence.
test/unit/cli/invite.spec.ts Unit tests for runInviteCreate, env-defaulting behavior, and error messaging/hints.
test/unit/cli/docs.spec.ts Ensures README/CLI docs mention the new invite-minting command.
test/unit/cli/cli.integration.spec.ts CLI spawn/integration coverage for invite top-level help/usage and validation.
src/utils/nip43-invites.ts New shared utilities to generate/issue invite codes and resolve defaults from settings.
src/repositories/invite-code-repository.ts Extends invite code persistence API to accept options (incl. createdBy).
src/cli/index.ts Registers invite create command, args/options parsing, and usage help wiring.
src/cli/commands/invite.ts Implements DB connection logic + runInviteCreate behavior and output formatting.
src/@types/repositories.ts Updates IInviteCodeRepository.create signature to accept an options object.
src/@types/invite-code.ts Adds CreateInviteCodeOptions type (expires/uses/createdBy).
resources/default-settings.yaml Adds nip43.inviteCodeExpiry and nip43.defaultMaxUses defaults.
README.md Documents how to mint NIP-43 invite codes via the CLI.
CONFIGURATION.md Adds configuration table entries for new nip43 settings.
CLI.md Adds dedicated section for NIP-43 invite minting + examples and semantics.
.knip.json Removes ignore entry now that repository file is referenced/used.
.changeset/nip43-invite-cli.md Declares a minor release for the new invite CLI feature.

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

Comment thread src/repositories/invite-code-repository.ts
Comment thread src/cli/index.ts
@Anshumancanrock
Anshumancanrock merged commit d413bd6 into cameri:main Aug 16, 2026
17 of 18 checks passed
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.

4 participants