feat: add remote trust and server identity pinning
Testing / remote-protocol-compat (0.16.0) (push) Successful in 1m1s
Testing / remote-protocol-compat (0.15.0) (push) Successful in 1m3s
Testing / test (push) Failing after 1m15s
Build & Publish Package / publish (push) Successful in 51s
Package Extension / package-extension (push) Successful in 1m6s
Testing / remote-protocol-compat (0.16.0) (push) Successful in 1m1s
Testing / remote-protocol-compat (0.15.0) (push) Successful in 1m3s
Testing / test (push) Failing after 1m15s
Build & Publish Package / publish (push) Successful in 51s
Package Extension / package-extension (push) Successful in 1m6s
- Add SSH-style server identity keys and known-host verification for remote serve endpoints. - Add remote add/list/remove commands for explicit endpoint persistence. - Fix remote clients listing to fan out through target discovery instead of ambiguous auto-routing. - Add URL glob matching for tabs filter and count with extension tests. - Add n8n credential pinning for server public keys or SHA256 fingerprints. - Remove obsolete compat shim behavior while keeping empty compat seams for future protocol changes. - Bump browser-cli to 0.16.4 and n8n node to 0.3.1. - Cover known-hosts, remote registry, compat seams, n8n protocol verification, and URL matching with tests.
This commit is contained in:
@@ -28,18 +28,39 @@ def is_valid_key_spec(value: str) -> bool:
|
||||
not value.startswith("<") and ("/" in value or Path(value).suffix in {".pem", ".key"})
|
||||
)
|
||||
|
||||
def save_remote_key(endpoint: str, key_spec: str) -> None:
|
||||
"""Persist the key spec (e.g. 'agent' or a file path) for a remote endpoint."""
|
||||
if not endpoint or not key_spec or not is_valid_key_spec(key_spec):
|
||||
def save_remote(endpoint: str, key_spec: str | None = None) -> None:
|
||||
"""Persist a remote endpoint, optionally with a key spec."""
|
||||
if not endpoint:
|
||||
return
|
||||
normalized = _normalize_endpoint(endpoint)
|
||||
remotes = load_remotes()
|
||||
current = remotes.get(endpoint, {})
|
||||
current["key"] = key_spec
|
||||
remotes[endpoint] = current
|
||||
current = remotes.get(normalized, {})
|
||||
if key_spec:
|
||||
if not is_valid_key_spec(key_spec):
|
||||
return
|
||||
current["key"] = key_spec
|
||||
remotes[normalized] = current
|
||||
REMOTE_REGISTRY_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
fd = os.open(str(REMOTE_REGISTRY_PATH), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
||||
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
||||
f.write(json.dumps(remotes, indent=2, sort_keys=True))
|
||||
f.write(json.dumps(remotes, indent=2, sort_keys=True) + "\n")
|
||||
|
||||
def remove_remote(endpoint: str) -> bool:
|
||||
"""Remove a remembered remote endpoint. Returns True when it existed."""
|
||||
normalized = _normalize_endpoint(endpoint)
|
||||
remotes = load_remotes()
|
||||
if normalized not in remotes:
|
||||
return False
|
||||
del remotes[normalized]
|
||||
REMOTE_REGISTRY_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
fd = os.open(str(REMOTE_REGISTRY_PATH), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
||||
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
||||
f.write(json.dumps(remotes, indent=2, sort_keys=True) + "\n")
|
||||
return True
|
||||
|
||||
def save_remote_key(endpoint: str, key_spec: str) -> None:
|
||||
"""Persist the key spec (e.g. 'agent' or a file path) for a remote endpoint."""
|
||||
save_remote(endpoint, key_spec)
|
||||
|
||||
def key_for_remote(endpoint: str | None) -> str | None:
|
||||
if not endpoint:
|
||||
|
||||
Reference in New Issue
Block a user