Files
marco/scripts/nostr-common.sh
T
raucao c30e8cee72
CI / Lint (pull_request) Successful in 55s
CI / Test (pull_request) Failing after 1m16s
Add NIP-05, category tags and the ngit repo to the app handler
Set content.nip05 (marco@kosmos.org), a ["t","maps"] category tag, and a
kind-30617 `a` tag linking the ngit repository — the three fields NostrHub's
app listing reads. Add the values as config in scripts/nostr-common.sh.
2026-11-28 17:50:35 +04:00

94 lines
3.9 KiB
Bash
Executable File

# Shared configuration for Marco's Nostr publishing scripts.
#
# Sourced (not executed) by:
# scripts/publish-app-handler.sh
# scripts/publish-app-recommendation.sh
# scripts/publish-nip.sh
#
# Nothing here is secret. Signing is done through nak with an explicit signer
# from the environment (nsec, hex, ncryptsec or a NIP-46 bunker:// URL).
# Prints an error and exits.
die() {
echo "error: $*" >&2
exit 1
}
# Relays every script publishes to. Edit scripts/nostr-relays.txt (one URL per
# line) instead of this file. An explicitly set NOSTR_RELAYS overrides it.
if [ -z "${NOSTR_RELAYS:-}" ]; then
RELAYS_FILE="${NOSTR_RELAYS_FILE:-$(dirname "$0")/nostr-relays.txt}"
[ -f "$RELAYS_FILE" ] || die "relay list not found: $RELAYS_FILE (create it or set NOSTR_RELAYS)"
NOSTR_RELAYS=$(
tr -d '\r' <"$RELAYS_FILE" |
sed -e 's/#.*//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' |
tr '\n' ' '
)
NOSTR_RELAYS=${NOSTR_RELAYS% }
[ -n "$NOSTR_RELAYS" ] || die "no relays found in $RELAYS_FILE"
fi
# 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"
# App metadata advertised in the handler:
# - NIP-05 identifier (goes into `content.nip05`)
# - category tags, one `["t", <tag>]` each (NostrHub shows these as
# hashtags/categories)
# - git repo reference: a kind-30617 `a` tag plus a relay hint
MARCO_APP_NIP05="marco@kosmos.org"
MARCO_APP_TAGS="maps"
MARCO_APP_REPO="30617:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco"
MARCO_APP_REPO_RELAY="wss://relay.ngit.dev"
# Author of the published NIP specs (kind 30817, "NIPs on Nostr"). A published
# spec can only be updated by this key; publishing from another key would fork
# the spec instead of replacing it, so the scripts guard against it.
NIP_SPEC_PUBKEY="1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb"
# Official NIPs Marco implements, advertised in the app handler (kind 31990) as
# NIP references so directories like NostrHub can list them. Space separated
# two-character identifiers (B7 is Blossom). See doc/nostr/nip-89-app-handler.md.
MARCO_NIPS="01 07 09 19 21 46 57 65 73 89 92 B7"
# "d" identifier of Marco's own published NIP (kind 30817): Place Photos and
# Videos. The app handler references it via its `a` address.
MARCO_NIP_PHOTOS_D="place-photos-and-videos"
# Relay hint for the custom NIP reference.
MARCO_NIP_RELAY="wss://nostr.kosmos.org"
# Requires an explicit signer so we never silently fall back to nak's machine
# default key. Exports NAK_SEC for the nak calls.
require_signer() {
command -v nak >/dev/null 2>&1 || die "nak is not installed (https://github.com/fiatjaf/nak)"
[ -n "${NOSTR_SECRET_KEY:-}" ] || die "set NOSTR_SECRET_KEY (nsec, hex, ncryptsec or bunker://...) first"
NAK_SEC="$NOSTR_SECRET_KEY"
export NAK_SEC
}
# Reads a signed event (nak prints compact, single-line JSON) on stdin and
# prints its pubkey.
event_pubkey() {
sed -n 's/.*"pubkey":"\([0-9a-f]\{64\}\)".*/\1/p'
}
# Refuses to continue when the signer is not the expected identity.
# $1 expected pubkey ("" skips the check), $2 actual pubkey.
assert_pubkey() {
if [ -n "$1" ] && [ "$2" != "$1" ]; then
die "signer is $2, expected $1 — wrong key for this event"
fi
}