feat: add a CLI to mint NIP-43 invite codes - #732
Conversation
🦋 Changeset detectedLatest commit: 47bae5e 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 |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 createCLI 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 persistcreated_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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
4a79e5c to
d3ddf0bCompared3ddf0b to
47bae5eCompareUh oh!
There was an error while loading. Please reload this page.
Description
Adds
nostream invite createso one can mint a NIP-43 claim without writing SQL.Defaults come from
nip43.defaultMaxUses(1) andnip43.inviteCodeExpiry(0 = never). Ifinfo.selfis hex ornpub1…, it gets stored ascreated_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_codesby hand. That's not usable.