Use the same about text as the app's kind-0 profile: "Unhosted maps app, enhancing OpenStreetMap with decentralized user data and content".
78 lines
2.4 KiB
Bash
Executable File
78 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Publish (or re-publish) Marco's NIP-89 app handler (kind 31990).
|
|
#
|
|
# Kind 31990 is addressable, so re-running this replaces the previous event
|
|
# (same author + "d" tag). See doc/nostr/nip-89-app-handler.md.
|
|
#
|
|
# Usage:
|
|
# NOSTR_SECRET_KEY='bunker://...' ./scripts/publish-app-handler.sh [--dry-run]
|
|
#
|
|
set -eu
|
|
|
|
. "$(dirname "$0")/nostr-common.sh"
|
|
|
|
DRY_RUN=0
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--dry-run) DRY_RUN=1 ;;
|
|
*) die "unknown argument: $arg" ;;
|
|
esac
|
|
done
|
|
|
|
require_signer
|
|
|
|
APP_ORIGIN="https://marco.earth"
|
|
APP_CONTENT="{\"name\":\"Marco\",\"about\":\"Unhosted maps app, enhancing OpenStreetMap with decentralized user data and content\",\"picture\":\"$APP_ORIGIN/icons/icon-192.png\",\"website\":\"$APP_ORIGIN\",\"nip05\":\"$MARCO_APP_NIP05\"}"
|
|
NIP_URL_PREFIX="https://github.com/nostr-protocol/nips/blob/master"
|
|
|
|
# "k" tags list every kind this app handles; add k=30360 when place reviews
|
|
# ship. Clients replace <bech32> with a NIP-19 nevent before opening the URL;
|
|
# the /e/<nevent> route is implemented in Marco (see the doc).
|
|
#
|
|
# "i" tags advertise the official NIPs Marco implements and an "a" tag points
|
|
# at Marco's own kind-30817 NIP. These are the shapes NostrHub's app directory
|
|
# reads (see doc/nostr/nip-89-app-handler.md).
|
|
set -- nak event --sec "$NAK_SEC" -k 31990 \
|
|
-d "$MARCO_APP_D" \
|
|
-t k=360 \
|
|
-t "web=$APP_ORIGIN/e/<bech32>;nevent" \
|
|
-c "$APP_CONTENT"
|
|
|
|
for nip in $MARCO_NIPS; do
|
|
set -- "$@" -t "i=$NIP_URL_PREFIX/$nip.md"
|
|
done
|
|
|
|
set -- "$@" -t "a=30817:$NIP_SPEC_PUBKEY:$MARCO_NIP_PHOTOS_D;$MARCO_NIP_RELAY;nip"
|
|
|
|
# Category tags (NostrHub shows these as hashtags/categories).
|
|
for tag in $MARCO_APP_TAGS; do
|
|
set -- "$@" -t "t=$tag"
|
|
done
|
|
|
|
# Git repo (ngit) reference: kind-30617 address plus relay hint.
|
|
set -- "$@" -t "a=$MARCO_APP_REPO;$MARCO_APP_REPO_RELAY"
|
|
|
|
event=$("$@")
|
|
|
|
pubkey=$(printf '%s\n' "$event" | event_pubkey)
|
|
[ -n "$pubkey" ] || die "could not read pubkey from the signed event"
|
|
assert_pubkey "$MARCO_APP_PUBKEY" "$pubkey"
|
|
|
|
if [ "$DRY_RUN" = 1 ]; then
|
|
printf '%s\n' "$event"
|
|
echo "dry run: signed by $pubkey, not published" >&2
|
|
exit 0
|
|
fi
|
|
|
|
printf '%s\n' "$event" | nak event $NOSTR_RELAYS
|
|
|
|
echo "published app handler (kind 31990) as $pubkey"
|
|
if [ -z "$MARCO_APP_PUBKEY" ]; then
|
|
echo "record MARCO_APP_PUBKEY=$pubkey in scripts/nostr-common.sh" >&2
|
|
fi
|
|
naddr=$(nak encode naddr -k 31990 -a "$pubkey" -d "$MARCO_APP_D" 2>/dev/null || true)
|
|
if [ -n "$naddr" ]; then
|
|
echo "naddr: $naddr"
|
|
fi
|