2# Pins the extension ID (section 14). Creates key.pem once (keep it out of the repo), writes the
3# public key into manifest.json, the ID into ./extension-id and into host/diagonal-host.py's
4# ALLOWED_ORIGIN, and prints the ID. Re-running with an existing key.pem changes nothing.
8if [[ ! -f key.pem ]]; then
9 openssl genrsa 2048 2>/dev/null | openssl pkcs8 -topk8 -nocrypt -out key.pem
11 echo "created key.pem (private; not needed unless you pack a .crx)" >&2
14KEY=$(openssl rsa -in key.pem -pubout -outform DER 2>/dev/null | openssl base64 -A)
15ID=$(openssl rsa -in key.pem -pubout -outform DER 2>/dev/null | openssl dgst -sha256 -binary | od -An -tx1 | tr -d " \n" | head -c 32 | tr 0-9a-f a-p)
17python3 - "$KEY" "$ID" <<'PY'
19key, ext_id = sys.argv[1], sys.argv[2]
20with open("manifest.json", encoding="utf-8") as f:
23with open("manifest.json", "w", encoding="utf-8") as f:
24 json.dump(m, f, indent=2, ensure_ascii=False)
26p = "host/diagonal-host.py"
27s = open(p, encoding="utf-8").read()
28s = re.sub(r'^ALLOWED_ORIGIN = ".*"$', f'ALLOWED_ORIGIN = "chrome-extension://{ext_id}/"', s, count=1, flags=re.M)
29open(p, "w", encoding="utf-8").write(s)
30open("extension-id", "w").write(ext_id + "\n")
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list