packaging/license-issuer/keygen.sh

14 lines · 851 bytes · executable

 1#!/bin/sh
 2# Makes the license signing key pair once: stores the private key as the Worker's
 3# LICENSE_PRIVATE_KEY secret and writes the public key into Sources/OrgApp/LicenseKey.swift.
 4# The private key is never written to disk; keep a copy in a password manager when prompted.
 5# Usage: packaging/license-issuer/keygen.sh
 6set -eu
 7cd "$(dirname "$0")"
 8pem="$(openssl genpkey -algorithm ed25519)"
 9public="$(printf '%s\n' "$pem" | openssl pkey -pubout -outform DER | tail -c 32 | base64)"
10printf '%s\n' "$pem" | npx wrangler secret put LICENSE_PRIVATE_KEY
11sed -i '' "s|public static let publicKey = .*|public static let publicKey = \"$public\"|" ../../Sources/OrgApp/LicenseKey.swift
12echo "Public key $public written to Sources/OrgApp/LicenseKey.swift; commit it."
13echo "Back up the private key now (it is not saved anywhere else):"
14printf '%s\n' "$pem"