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.
58 lines
1.6 KiB
Bash
Executable File
58 lines
1.6 KiB
Bash
Executable File
#!/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"
|