Publish the app handler under the author's npub
CI / Lint (pull_request) Successful in 51s
CI / Test (pull_request) Successful in 1m11s

Move the handler identity from the dedicated app key to the author's own
npub (the same key that authors the NIP specs), and add
scripts/unpublish-app-handler.sh to delete an old handler via a NIP-09
kind-5 event. Document the identity and the retirement flow.
This commit is contained in:
raucao committed 2026-11-28 17:33:53 +04:00
1 parent 5300cc1dc8
commit 38ca6ba296
3 files changed
+95 -28

No files matched your search

+28 -23
View File
@@ -11,29 +11,30 @@ declares itself as the handler for the place media kinds it defines:
Two events are involved:
| Event | Kind | Published by | Purpose |
| -------------- | ------- | --------------------------- | --------------------------------------------------- |
| App handler | `31990` | dedicated **Marco app** key | Describes Marco and where to open each handled kind |
| Recommendation | `31989` | a **user** key | Recommends Marco's handler to that user's followers |
| Event | Kind | Published by | Purpose |
| -------------- | ------- | --------------------- | --------------------------------------------------- |
| App handler | `31990` | the author's **npub** | Describes Marco and where to open each handled kind |
| Recommendation | `31989` | a **user** key | Recommends Marco's handler to that user's followers |
Both are addressable: re-publishing with the same author and `d` tag replaces
the previous event.
## Identity
Marco's app handler is signed by a **dedicated "Marco app" key**, separate from
any person's account and from the key that authors the NIP specs. Its pubkey is
recorded here once the key exists:
Marco's app handler is signed by the author's own npub — the same identity that
authors the NIP specs — so it appears on NostrHub under a real Nostr account
rather than a separate app key:
```
pubkey: <marco-app-pubkey>
npub: <marco-app-npub>
naddr: <31990 naddr>
pubkey: 1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb
npub: npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees
naddr: naddr1qq9k6ctjvdhjuetpwf6xsq3qraustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89sxpqqqp70va9myaa
```
The key itself is never stored in this repository. The publishing scripts
sign through `nak` with an explicit signer from `NOSTR_SECRET_KEY` (an
`nsec`/hex key, or a NIP-46 `bunker://` URL for a desktop signer). See
The key itself is never stored in this repository. The publishing scripts sign
through `nak` with an explicit signer from `NOSTR_SECRET_KEY` (an `nsec`/hex
key, or a NIP-46 `bunker://` URL for a desktop signer), and `MARCO_APP_PUBKEY`
in `scripts/nostr-common.sh` guards against signing from any other key. See
[`publishing.md`](./publishing.md) for the shared setup.
## App handler event (`kind 31990`)
@@ -41,7 +42,7 @@ sign through `nak` with an explicit signer from `NOSTR_SECRET_KEY` (an
```json
{
"kind": 31990,
"pubkey": "<marco-app-pubkey>",
"pubkey": "1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb",
"content": "{\"name\":\"Marco\",\"about\":\"An unhosted maps application.\",\"picture\":\"https://marco.earth/icons/icon-192.png\",\"website\":\"https://marco.earth\"}",
"tags": [
["d", "marco.earth"],
@@ -73,7 +74,7 @@ sign through `nak` with an explicit signer from `NOSTR_SECRET_KEY` (an
account users follow, Marco carries its name/description/icon/website here
instead of (or in addition to) a `kind 0`.
- **`d`** is `marco.earth`, so the addressable coordinate is
`31990:<marco-app-pubkey>:marco.earth`.
`31990:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco.earth`.
- **`k`** lists every event kind Marco handles. Add `["k", "30360"]` when place
reviews ship.
- **`web`** is a URL template. Clients replace `<bech32>` with the NIP-19
@@ -138,13 +139,13 @@ Published from a _user's_ account (`scripts/publish-app-recommendation.sh`):
["d", "360"],
[
"a",
"31990:<marco-app-pubkey>:marco.earth",
"31990:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco.earth",
"wss://nostr.kosmos.org",
"web"
],
[
"a",
"31990:<marco-app-pubkey>:marco.earth",
"31990:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco.earth",
"wss://relay.primal.net",
"web"
]
@@ -167,15 +168,19 @@ edit that file to change where events are sent. An explicitly set
## Publishing
```sh
# app handler, signed by the Marco app key
# app handler, signed by the author's own npub
NOSTR_SECRET_KEY='bunker://...' ./scripts/publish-app-handler.sh
# recommendation, signed by your own key (after MARCO_APP_PUBKEY is set)
# recommendation, signed by your own key
NOSTR_SECRET_KEY='<your key or bunker>' ./scripts/publish-app-recommendation.sh
# add --dry-run to either script to sign and print without publishing
# retire an old handler (only its author key can delete it)
NOSTR_SECRET_KEY='<old app key>' ./scripts/unpublish-app-handler.sh --dry-run
NOSTR_SECRET_KEY='<old app key>' ./scripts/unpublish-app-handler.sh
# add --dry-run to any script to sign and print without publishing
```
The first app-handler run prints the app pubkey and its `naddr`; paste the
pubkey into `MARCO_APP_PUBKEY` in `scripts/nostr-common.sh` and record the
identifiers above.
`MARCO_APP_PUBKEY` in `scripts/nostr-common.sh` holds the handler's author npub;
the scripts refuse to sign from any other key. `unpublish-app-handler.sh`
targets `MARCO_OLD_APP_PUBKEY` by default (pass a pubkey to override).
+10 -5
View File
@@ -28,11 +28,16 @@ if [ -z "${NOSTR_RELAYS:-}" ]; then
[ -n "$NOSTR_RELAYS" ] || die "no relays found in $RELAYS_FILE"
fi
# Hex pubkey of the dedicated "Marco app" identity that signs the NIP-89 app
# handler (kind 31990). Leave empty until the key exists; after the first
# successful publish-app-handler.sh run, paste the printed pubkey here so the
# scripts refuse to publish from the wrong identity.
MARCO_APP_PUBKEY=""
# Hex pubkey that signs and therefore owns Marco's NIP-89 app handler
# (kind 31990). This is the author's own npub (the same identity that authors
# the NIP specs), so the handler appears under a real Nostr identity rather
# than a separate app key. The scripts refuse to publish from any other key.
MARCO_APP_PUBKEY="1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb"
# The previous dedicated "Marco app" key. Its handler (same `d`) is a separate
# addressable coordinate that must be deleted explicitly with
# scripts/unpublish-app-handler.sh. Safe to remove once it is gone.
MARCO_OLD_APP_PUBKEY="72424a5bdb8b3e6bcb2731643d43b26f3e3750ae61e5d601719aabd12ee94316"
# "d" identifier of Marco's NIP-89 app handler (kind 31990).
MARCO_APP_D="marco.earth"
+57
View File
@@ -0,0 +1,57 @@
#!/bin/sh
#
# Delete (unpublish) a NIP-89 app handler (kind 31990) by publishing a NIP-09
# kind-5 deletion for its addressable coordinate. Only the handler's own author
# key can delete it, so NOSTR_SECRET_KEY must be the key that signed it.
#
# Used to retire Marco's old handler after moving it to the author's own npub.
#
# Usage:
# NOSTR_SECRET_KEY='<old app key>' ./scripts/unpublish-app-handler.sh [<pubkey>] [--dry-run]
#
# <pubkey> defaults to MARCO_OLD_APP_PUBKEY in scripts/nostr-common.sh.
#
set -eu
. "$(dirname "$0")/nostr-common.sh"
DRY_RUN=0
TARGET_PUBKEY="$MARCO_OLD_APP_PUBKEY"
for arg in "$@"; do
case "$arg" in
--dry-run) DRY_RUN=1 ;;
*[!0-9a-fA-F]* | '') die "invalid pubkey: $arg" ;;
*) TARGET_PUBKEY="$arg" ;;
esac
done
[ -n "$TARGET_PUBKEY" ] || die "no pubkey to unpublish (set MARCO_OLD_APP_PUBKEY or pass one)"
TARGET_PUBKEY=$(printf '%s' "$TARGET_PUBKEY" | tr 'A-F' 'a-f')
# Addressable handler coordinate, e.g. 31990:<pubkey>:marco.earth
address="31990:$TARGET_PUBKEY:$MARCO_APP_D"
require_signer
# NIP-09: a parameterized replaceable event is deleted with an `a` tag pointing
# at its coordinate (the `k` tag names the kind being deleted).
event=$(
nak event --sec "$NAK_SEC" -k 5 \
-t "a=$address" \
-t k=31990 \
-c ''
)
pubkey=$(printf '%s\n' "$event" | event_pubkey)
[ -n "$pubkey" ] || die "could not read pubkey from the signed event"
assert_pubkey "$TARGET_PUBKEY" "$pubkey"
if [ "$DRY_RUN" = 1 ]; then
printf '%s\n' "$event"
echo "dry run: deletion signed by $pubkey, not published" >&2
exit 0
fi
printf '%s\n' "$event" | nak event $NOSTR_RELAYS
echo "published deletion for $address as $pubkey"