feat: add name field to npubs#2
Open
sh1ftred wants to merge 1 commit into
Open
Conversation
- Add nullable 'name' column to routstr_auth_npubs table - Auto-migrate existing DBs with ALTER TABLE ADD COLUMN - Accept 'name' in POST /npubs (add) and PATCH /npubs (update) - PATCH /npubs now accepts 'role' and/or 'name' (at least one required) - name can be set to null to clear it - Only admins can update names (same as roles) - Include 'name' in GET /npubs, POST /npubs, and PATCH /npubs responses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
namefield to registered npubs, allowing admins to assign human-readable labels to npub entries. This works the same way as the existingrolefield — set it at creation time, update it later.Changes
namecolumn onroutstr_auth_npubstable, auto-migrated from older DBs viaALTER TABLE ADD COLUMNNpubEntryinterface: Addedname: string | nullAuthStore.addNpub(): Accepts optionalnameparameterAuthStore.updateNpubName(): New method (mirrorsupdateNpubRole())POST /npubs: Accepts optional"name"field in the bodyPATCH /npubs: Now accepts"role"and/or"name"(at least one required, admin-only)GET /npubs: Includesnamein the responsenamemust be a string ornull; passing anything else returns a 400 errorAPI Usage for External Clients
Set a name when adding an npub
Update an npub's name (admin only)
Just like updating a role, use
PATCH /npubswith NIP-98 admin auth:List npubs with names
curl http://localhost:8008/npubs # => { "npubs": [{ "npub": "npub1...", "name": "Alice", "role": "admin" }, ...] }Backward Compatibility
namecolumn is added on first runnamefield is optional in all request bodies (defaults tonull)PATCH /npubsendpoint previously requiredrole; now it requires at least one ofroleorname