Repository Public
1#!/usr/bin/env bash2# SP Wallet iOS3# File: Scripts/check-release.sh4# Description: Refuses a release build that is not what it must be: no test passkey code, no development origin, no local5# networking, no web view, the production origin and relying party, the expected entitlements, a privacy manifest.6# usage: check-release.sh <path to SPWallet.app> [--distribution]7# (--distribution, for the exported IPA: also requires a distribution signature, i.e. get-task-allow false;8# an archive is development-signed and is re-signed at export)9#10# Author: Simon-Pierre Boucher11# Contact: contact@spboucher.ai12set -uo pipefail13APP="${1:?path to SPWallet.app}"14BIN="$APP/SPWallet"15fail=016ok() { echo " ok $1"; }17ko() { echo " FAIL $1"; fail=1; }1819# 1. nothing of the software passkey / throwaway-stack support may be linked into a release binary20if nm -a "$BIN" 2>/dev/null | grep -q -E "SoftwareAuthenticator|DevStackSetup"; then ko "test passkey symbols present in the binary"; else ok "no test passkey symbol"; fi21if strings - "$BIN" | grep -q -E "SPWALLET_ORIGIN|SPWALLET_DEV_DIR|software-passkey|spw-native-"; then ko "development override strings present"; else ok "no development override"; fi22if strings - "$BIN" | grep -q -E "http://localhost|http://127\.0\.0\.1"; then ko "a loopback URL is compiled in"; else ok "no loopback URL"; fi23# 2. no web view anywhere (app and extensions)24if find "$APP" -type f \( -name SPWallet -o -name SPWalletWidgets \) -exec nm -u {} \; 2>/dev/null | grep -q -E "WKWebView|SFSafariViewController|UIWebView"; then ko "a web view class is referenced"; else ok "no web view"; fi25if otool -L "$BIN" | grep -q -E "WebKit|SafariServices"; then ko "WebKit / SafariServices linked"; else ok "WebKit not linked"; fi26# 3. production configuration27P() { /usr/libexec/PlistBuddy -c "Print :$1" "$APP/Info.plist" 2>/dev/null; }28[[ "$(P SPWalletOrigin)" == "https://wallet.spboucher.ai" ]] && ok "origin https://wallet.spboucher.ai" || ko "origin is $(P SPWalletOrigin)"29[[ "$(P SPWalletRelyingParty)" == "wallet.spboucher.ai" ]] && ok "relying party wallet.spboucher.ai" || ko "relying party is $(P SPWalletRelyingParty)"30[[ "$(P NSAppTransportSecurity:NSAllowsArbitraryLoads)" == "false" ]] && ok "ATS: no arbitrary loads" || ko "ATS allows arbitrary loads"31[[ "$(P NSAppTransportSecurity:NSAllowsLocalNetworking)" == "false" ]] && ok "ATS: no local networking" || ko "ATS allows local networking"32# 4. entitlements actually signed into the app33ENT=$(codesign -d --entitlements - --xml "$APP" 2>/dev/null | plutil -convert json -o - - 2>/dev/null)34ent() { echo "$ENT" | python3 -c "import sys,json; d=json.load(sys.stdin); v=d.get('$1'); print(json.dumps(v))" 2>/dev/null; }35[[ "$(ent com.apple.developer.associated-domains)" == '["webcredentials:wallet.spboucher.ai"]' ]] && ok "associated domain webcredentials:wallet.spboucher.ai (and no other)" || ko "associated domains are $(ent com.apple.developer.associated-domains)"36[[ "$(ent com.apple.security.application-groups)" == '["group.ai.spboucher.spwallet.ios"]' ]] && ok "app group" || ko "app groups are $(ent com.apple.security.application-groups)"37if [[ "${2:-}" == "--distribution" ]]; then38 [[ "$(ent get-task-allow)" == "false" ]] && ok "distribution signature (get-task-allow false)" || ko "get-task-allow is $(ent get-task-allow)"39 SIGNER=$(codesign -dvv "$APP" 2>&1 || true)40 [[ "$SIGNER" == *"Authority=Apple Distribution"* ]] && ok "signed with Apple Distribution" || ko "not signed with Apple Distribution"41fi42codesign --verify --deep --strict "$APP" 2>/dev/null && ok "signature verifies" || ko "signature does not verify"43# 5. privacy manifest, widgets44[[ -f "$APP/PrivacyInfo.xcprivacy" ]] && ok "privacy manifest" || ko "privacy manifest missing"45[[ -d "$APP/PlugIns/SPWalletWidgets.appex" ]] && ok "widget extension embedded" || ko "widget extension missing"46[[ $fail -eq 0 ]] && echo "release checks passed" || { echo "release checks FAILED"; exit 1; }47