diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-19 17:58:05 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-19 17:58:05 +0200 |
| commit | 1ec316035ce9aa656dd18a05889856bce9e3aba3 (patch) | |
| tree | b50e97f50d485ef2a88ce36fe4d7511d9fe3e288 /poc/spike3_node.py | |
| parent | 171a3e175889ce30f201fcdf5c4632f480344ae6 (diff) | |
| parent | 95dd3dc13aecec85c2fd72410cd4d1f4ed582dfa (diff) | |
| download | meshbay-1ec316035ce9aa656dd18a05889856bce9e3aba3.tar.gz | |
Merge origin/main: the tree-wide ruff pass beside the Music reconnect work
Diffstat (limited to 'poc/spike3_node.py')
| -rw-r--r-- | poc/spike3_node.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/poc/spike3_node.py b/poc/spike3_node.py index c0ddde0..562239f 100644 --- a/poc/spike3_node.py +++ b/poc/spike3_node.py @@ -12,17 +12,23 @@ Sequence: 8. Simulate token refresh """ -import asyncio, httpx, base64, json, os, time +import asyncio +import base64 +import json +import time from pathlib import Path + +import httpx +import jwt +from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey -from cryptography.hazmat.primitives import serialization -import jwt HUB_URL = "http://meshbay.org" STATE_FILE = Path("node_state.json") # persists keys and tokens between runs -PASS = "✓"; FAIL = "✗" +PASS = "✓" +FAIL = "✗" # ── Key helpers ─────────────────────────────────────────────────────────────── @@ -52,7 +58,7 @@ def _load_or_generate_keys(state: dict) -> tuple: sk_x = X25519PrivateKey.generate() state["sk_ed25519_b64"] = _sk_to_b64(sk_ed) state["sk_x25519_b64"] = _sk_to_b64(sk_x) - print(f" Generated new keypair") + print(" Generated new keypair") return sk_ed, sk_x # ── Main ────────────────────────────────────────────────────────────────────── @@ -101,7 +107,7 @@ async def main(): state["user_id"] = r.json()["user_id"] print(f" {PASS} Registered — user_id={state['user_id'][:8]}...") elif r.status_code == 409: - print(f" Already registered (409) — continuing with existing account") + print(" Already registered (409) — continuing with existing account") else: raise RuntimeError(f"Register failed: {r.status_code} {r.text}") @@ -149,7 +155,7 @@ async def main(): node_id = r.json()["node_id"] state["node_id"] = node_id print(f" {PASS} Node announced — node_id={node_id[:8]}...") - print(f" endpoint_hint : None (STUN/UPnP discovery in Spike 4)") + print(" endpoint_hint : None (STUN/UPnP discovery in Spike 4)") # ── Step 7: Retrieve node record ────────────────────────────────────── print("\n[ 7 ] Retrieve node record from hub") |