Files
buzz/mobile/scripts/require-push-gateway-origin.sh
Tom Brow 76f7e5ef0c feat(push): make gateway origin configurable (#7261)
Make the push gateway origin configurable across the relay, gateway,
mobile client, and deployment chart.

This is a fresh deployment. The gateway has only run on personal
development infrastructure, and push has no existing enabled users.
Legacy migration, configured-to-unconfigured mobile transitions, and
rolling upgrades from pre-launch gateway binaries are not supported.

Populated pre-launch databases are rejected with an informative error
before migrations run; their data is untouched. Mobile builds may omit
the gateway URL, leaving push unavailable. Once push is enabled,
subsequent builds must retain that configuration.

### Validation

- All applicable CI checks pass at
`5f546cfaf403f0386f146d213adfb4392f4ec29c`, including Rust,
mobile/Swift, desktop/integration, security, image builds, and Helm
checks. An unrelated agent cancellation test passed on retry.
- PostgreSQL CI passed 384 tests, including the production-entry-point
regression for refusing populated pre-launch databases before
migrations, fresh initialization, and subsequent initialized
deployments.
- Focused local validation passed all 10 gateway PostgreSQL tests under
the CI discovery filter and all 3 unconfigured-mobile tests.
Repository-wide PostgreSQL discovery validation and the complete
pre-push hooks passed.
- Physical-device APNs/App Attest behavior and deployment to a live
cluster were not verified in this work.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Codex <noreply@openai.com>
2026-09-15 14:56:45 -07:00

56 lines
1.6 KiB
Bash

#!/bin/sh
set -eu
gateway_origin=
has_dart_define=false
old_ifs=$IFS
IFS=','
for encoded in ${DART_DEFINES:-}; do
decoded=$(printf '%s' "$encoded" | base64 --decode 2>/dev/null || printf '%s' "$encoded" | base64 -D 2>/dev/null || true)
case "$decoded" in
BUZZ_PUSH_GATEWAY_URL=*)
if [ "$has_dart_define" = true ]; then
echo "error: BUZZ_PUSH_GATEWAY_URL must be supplied at most once." >&2
exit 1
fi
has_dart_define=true
gateway_origin=${decoded#BUZZ_PUSH_GATEWAY_URL=}
;;
esac
done
IFS=$old_ifs
if [ "$has_dart_define" = false ] && [ -n "${BUZZ_PUSH_GATEWAY_URL:-}" ]; then
gateway_origin=$BUZZ_PUSH_GATEWAY_URL
encoded=$(printf '%s' "BUZZ_PUSH_GATEWAY_URL=$gateway_origin" | base64 | tr -d '\n')
DART_DEFINES=${DART_DEFINES:+$DART_DEFINES,}$encoded
export DART_DEFINES
fi
if [ "$has_dart_define" = false ] && [ -z "$gateway_origin" ]; then
# An unconfigured artifact deliberately has no push capability.
return 0 2>/dev/null || exit 0
fi
if [ -n "${SRCROOT:-}" ]; then
script_dir=$SRCROOT/../scripts
else
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
fi
dart_bin=${FLUTTER_ROOT:+$FLUTTER_ROOT/bin/dart}
if [ -z "$dart_bin" ] || [ ! -x "$dart_bin" ]; then
dart_bin=$(command -v dart || true)
fi
if [ -z "$dart_bin" ]; then
echo "error: Dart is required to validate BUZZ_PUSH_GATEWAY_URL." >&2
exit 1
fi
case ${CONFIGURATION:-Release} in
Debug*)
"$dart_bin" "$script_dir/validate_push_gateway_origin.dart" "$gateway_origin"
;;
*)
"$dart_bin" "$script_dir/validate_push_gateway_origin.dart" --require-https "$gateway_origin"
;;
esac