Googstr/scripts/vendor-nostr-tools.sh
Jason Tudisco fcfaec675a Add NIP-46 signer, optional NIP-07 extension, passkey protection, backups
- NIP-46 remote signer in the page (bunker:// and nostrconnect:// pairing)
- Chrome extension (NIP-07) with per-site permission prompts, unlocked by
  the site via externally_connectable; downloadable from the page
- Passkey (WebAuthn PRF) encryption of the Drive key file
- NIP-49 backups: download or save to Drive; reveal nsec
- Fix: oldest key file wins when two devices sign up at once
- Fix: never overwrite an existing kind-0 because a relay was slow
- Fix: EOSE tracking; relays reconnect with backoff; verify event signatures
- One-click re-sign-in (consent only the first time)
- Vendored, pinned nostr-tools; CSP; no third-party scripts but Google's

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 08:33:02 -06:00

25 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# Rebuild public/vendor/nostr-tools.js — a pinned, self-contained ESM bundle of
# just the nostr-tools pieces Goostr uses. Only needed when upgrading.
set -e
VERSION=2.25.2
ROOT=$(cd "$(dirname "$0")/.." && pwd)
TMP=$(mktemp -d)
cd "$TMP"
npm init -y >/dev/null
npm install --silent "nostr-tools@$VERSION" esbuild@0.25
cat > entry.js <<'JS'
export { generateSecretKey, getPublicKey, finalizeEvent, verifyEvent } from "nostr-tools/pure";
export * as nip19 from "nostr-tools/nip19";
export * as nip04 from "nostr-tools/nip04";
export * as nip44 from "nostr-tools/nip44";
export * as nip49 from "nostr-tools/nip49";
export { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
JS
mkdir -p "$ROOT/public/vendor" "$ROOT/extension/vendor"
npx esbuild entry.js --bundle --format=esm --minify --legal-comments=inline \
--banner:js="// nostr-tools@$VERSION (MIT) — built by scripts/vendor-nostr-tools.sh" \
--outfile="$ROOT/public/vendor/nostr-tools.js"
cp "$ROOT/public/vendor/nostr-tools.js" "$ROOT/extension/vendor/"
rm -rf "$TMP"