18 lines
1.4 KiB
Bash
18 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
# Bundles the offline receipt verifier into one plain-JavaScript file (site/lc/verify-receipt.js) with esbuild: the
|
|
# noble libraries inlined, Node built-ins external, no npm at run time. Runs on the build box (nothing heavy on the Mac):
|
|
# tools/reference-apps/receipt/bundle.sh from the worktree root; needs node and npx (esbuild is fetched by npx)
|
|
# The bundle is committed beside the pages: the site deploys from site/ alone and installs nothing.
|
|
set -euo pipefail
|
|
cd "$(git rev-parse --show-toplevel)"
|
|
SRC=tools/reference-apps/receipt/verify-receipt.src.mjs
|
|
OUT=site/lc/verify-receipt.js
|
|
mkdir -p site/lc
|
|
( cd tools/reference-apps/light-service && [ -d node_modules/@noble/curves ] || npm install --no-audit --no-fund >/dev/null )
|
|
NODE_PATH=tools/reference-apps/light-service/node_modules npx --yes esbuild@0.24.2 "$SRC" --bundle --platform=node --format=cjs --target=node18 --legal-comments=inline \
|
|
--banner:js="#!/usr/bin/env node
|
|
// Igneum transaction inclusion receipt verifier, one file, offline. Source: tools/reference-apps/receipt/verify-receipt.src.mjs and site/lc/core.js
|
|
// (the same checks the browser page runs), bundled with @noble/hashes 2.4.0 and @noble/curves 2.4.0 (MIT). Usage: node verify-receipt.js receipt.json [--tamper]" \
|
|
--outfile="$OUT"
|
|
chmod +x "$OUT"
|
|
echo "bundled $OUT: $(wc -c < "$OUT") bytes, sha256 $(sha256sum "$OUT" | cut -c1-16)"
|