From 988a0eecd522431980174910db28e45a63ff2710 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Thu, 15 Oct 2026 12:32:24 +0200 Subject: feat(cli): account, rm -r and mkdir, Tab completion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit account shows the account and does what the sign-up form and the Profile page do: register (the passphrase floor and the hub's proof of work checked here, the recovery key printed once), verify, change the passphrase, reset a forgotten one, change the e-mail address, sign out everywhere, delete. A new passphrase carries the copy of the account's keys each node keeps for browsers first — opened under the old M, the same keys sealed under the new one — and only then tells the hub; a refusal sets the copies back. A reset restores them from the recovery copy. The connections that do it never make keys nor ask for a device approval. This machine keeps the M it changed away from, so a node out of reach is carried at its next connection; a copy under an M it does not know is no longer rewritten, which locked the browsers out after a passphrase changed elsewhere. rm -r removes a folder and all it holds, from the node's operator key: the files, then the folders deepest first, one confirmation that counts them. mkdir makes folders, --parents the missing ones (not -p, the passphrase). completion bash|powershell prints the script that makes Tab complete actions, verbs, options and the paths of the groups this machine is signed in to, cached two minutes; the deb and rpm packages install the bash one. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-cli/src/meshbay_cli/client/hub.py | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'packages/meshbay-cli/src/meshbay_cli/client/hub.py') diff --git a/packages/meshbay-cli/src/meshbay_cli/client/hub.py b/packages/meshbay-cli/src/meshbay_cli/client/hub.py index 94d22da..5b301f8 100644 --- a/packages/meshbay-cli/src/meshbay_cli/client/hub.py +++ b/packages/meshbay-cli/src/meshbay_cli/client/hub.py @@ -120,6 +120,66 @@ class Hub: async def me(self, token: str) -> dict: return await self._call("GET", "/v1/users/me", token=token) + # ── The account ────────────────────────────────────────────────────────── + + async def captcha(self) -> dict | None: + """A proof-of-work challenge, or None when this hub has the check off.""" + try: + return await self._call("GET", "/v1/users/captcha") + except HubError as e: + if e.status == 404: + return None + raise + + async def register(self, username: str, email: str, auth_key: str, + recovery_key: str | None, captcha_token: str | None) -> dict: + body = {"username": username, "email": email, "auth_key": auth_key} + if recovery_key: + body["recovery_key"] = recovery_key + if captcha_token: + body["captcha_token"] = captcha_token + return await self._call("POST", "/v1/users/register", json=body) + + async def verify_email(self, email: str, code: str) -> dict: + return await self._call("POST", "/v1/users/verify-email", + json={"email": email, "code": code}) + + async def bundle_pepper(self, token: str, auth_key: str) -> dict: + return await self._call("POST", "/v1/users/me/bundle-pepper", token=token, + json={"auth_key": auth_key}) + + async def change_passphrase(self, token: str, old_auth_key: str, + new_auth_key: str) -> dict: + return await self._call("POST", "/v1/users/password", token=token, + json={"old_auth_key": old_auth_key, + "new_auth_key": new_auth_key}) + + async def reset_request(self, username: str, email: str, + captcha_token: str | None) -> dict: + body = {"username": username, "email": email} + if captcha_token: + body["captcha_token"] = captcha_token + return await self._call("POST", "/v1/users/password/reset-request", json=body) + + async def reset_passphrase(self, username: str, code: str, new_auth_key: str) -> dict: + return await self._call("POST", "/v1/users/password/reset", json={ + "username": username, "code": code, "new_auth_key": new_auth_key}) + + async def change_email(self, token: str, email: str, auth_key: str) -> dict: + return await self._call("PATCH", "/v1/users/me", token=token, + json={"email": email, "auth_key": auth_key}) + + async def verify_email_change(self, token: str, code: str) -> dict: + return await self._call("POST", "/v1/users/verify-email-change", token=token, + json={"code": code}) + + async def revoke_sessions(self, token: str) -> dict: + return await self._call("POST", "/v1/users/me/sessions/revoke", token=token) + + async def delete_account(self, token: str, auth_key: str) -> dict: + return await self._call("DELETE", "/v1/users/me", token=token, + json={"auth_key": auth_key}) + # ── Groups and nodes ───────────────────────────────────────────────────── async def my_groups(self, token: str) -> list[dict]: -- cgit v1.2.3