From 471a4b1634a45410f2f2b11ee5859b9f794e8a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz?= Date: Fri, 3 Apr 2026 11:54:53 +0200 Subject: [PATCH 1/4] Add version to python module --- ooniauth-py/ooniauth_py.pyi | 6 ++++++ ooniauth-py/src/lib.rs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ooniauth-py/ooniauth_py.pyi b/ooniauth-py/ooniauth_py.pyi index fe37153..c6f8ea0 100644 --- a/ooniauth-py/ooniauth_py.pyi +++ b/ooniauth-py/ooniauth_py.pyi @@ -4,6 +4,8 @@ import builtins import typing +__version__: str + class CredentialError(builtins.Exception): r""" An authentication error @@ -34,6 +36,7 @@ class ServerState: This is meant to be used by the server, so it can store the keys somewhere and recreate the state when needed """ + def get_secret_key(self) -> str: ... def get_public_parameters(self) -> str: ... def handle_registration_request(self, registration_request: str) -> str: ... @@ -70,6 +73,7 @@ class UserState: Note that this function will only work if you previously called `make_registration_request` """ + def make_submit_request( self, probe_cc: str, probe_asn: str, emission_date: builtins.int ) -> SubmitRequest: ... @@ -80,10 +84,12 @@ class UserState: Note that this function will only work if you previously called `make_submit_request` """ + def make_credential_update_request(self) -> str: r""" Creates a credential update request to be sent to the server. """ + def handle_credential_update_response(self, resp: str) -> None: r""" Handles the credential update response sent by the server, updating your credentials. diff --git a/ooniauth-py/src/lib.rs b/ooniauth-py/src/lib.rs index c18c35c..a4b2286 100644 --- a/ooniauth-py/src/lib.rs +++ b/ooniauth-py/src/lib.rs @@ -8,9 +8,12 @@ mod utils; pub use exceptions::*; pub use protocol::*; +pyo3_stub_gen::module_variable!("ooniauth-py", "__version__", &str); + /// Here we define the python module itself and its members #[pymodule] fn ooniauth_py(m: &Bound<'_, PyModule>) -> PyResult<()> { + m.add("__version__", env!("CARGO_PKG_VERSION"))?; m.add_class::()?; m.add_class::()?; m.add_class::()?; From c6b10d4ad24cb48896b2c613b938f1657dcfecdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz?= Date: Fri, 3 Apr 2026 12:07:55 +0200 Subject: [PATCH 2/4] Add functions to get protocol version --- ooniauth-core/src/lib.rs | 3 +++ ooniauth-py/ooniauth_py.pyi | 7 ++++++- ooniauth-py/src/lib.rs | 1 + ooniauth-py/src/protocol.rs | 9 ++++++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ooniauth-core/src/lib.rs b/ooniauth-core/src/lib.rs index 29b5088..2ca3d19 100644 --- a/ooniauth-core/src/lib.rs +++ b/ooniauth-core/src/lib.rs @@ -2,6 +2,9 @@ // to be capital letters #![allow(non_snake_case)] +/// Version of this crate (`ooniauth-core`), from `Cargo.toml`. +pub const VERSION: &str = env!("CARGO_PKG_VERSION"); + use cmz::*; use curve25519_dalek::ristretto::RistrettoPoint as G; use group::Group; diff --git a/ooniauth-py/ooniauth_py.pyi b/ooniauth-py/ooniauth_py.pyi index c6f8ea0..9b8e0ac 100644 --- a/ooniauth-py/ooniauth_py.pyi +++ b/ooniauth-py/ooniauth_py.pyi @@ -4,7 +4,7 @@ import builtins import typing -__version__: str +__version__: builtins.str class CredentialError(builtins.Exception): r""" @@ -96,3 +96,8 @@ class UserState: This function only works if you previosly called `make_credential_update_request` """ + +def get_protocol_version() -> builtins.str: + r""" + Returns the version of the `ooniauth-core`, the actual protocol implementation. + """ diff --git a/ooniauth-py/src/lib.rs b/ooniauth-py/src/lib.rs index a4b2286..458cece 100644 --- a/ooniauth-py/src/lib.rs +++ b/ooniauth-py/src/lib.rs @@ -14,6 +14,7 @@ pyo3_stub_gen::module_variable!("ooniauth-py", "__version__", &str); #[pymodule] fn ooniauth_py(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add("__version__", env!("CARGO_PKG_VERSION"))?; + m.add_function(wrap_pyfunction!(get_protocol_version, m)?)?; m.add_class::()?; m.add_class::()?; m.add_class::()?; diff --git a/ooniauth-py/src/protocol.rs b/ooniauth-py/src/protocol.rs index 3ac6e5e..02b3124 100644 --- a/ooniauth-py/src/protocol.rs +++ b/ooniauth-py/src/protocol.rs @@ -8,11 +8,18 @@ use pyo3::{ prelude::*, types::{PyList, PyString}, }; -use pyo3_stub_gen::derive::{gen_stub_pyclass, gen_stub_pymethods}; +use pyo3_stub_gen::derive::{gen_stub_pyclass, gen_stub_pyfunction, gen_stub_pymethods}; use crate::utils::{from_pystring, to_pystring}; use crate::{exceptions::OoniResult, OoniErr}; +/// Returns the version of the `ooniauth-core`, the actual protocol implementation. +#[gen_stub_pyfunction(module = "ooniauth-py")] +#[pyfunction] +pub fn get_protocol_version() -> &'static str { + ooniauth_core::VERSION +} + #[gen_stub_pyclass] #[pyclass] pub struct ServerState { From 213fb3ee6631c3df0286a12aaac692c1cbc54c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz?= Date: Fri, 3 Apr 2026 12:16:06 +0200 Subject: [PATCH 3/4] Move version variable down the same file --- ooniauth-core/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ooniauth-core/src/lib.rs b/ooniauth-core/src/lib.rs index 2ca3d19..674d0ba 100644 --- a/ooniauth-core/src/lib.rs +++ b/ooniauth-core/src/lib.rs @@ -2,9 +2,6 @@ // to be capital letters #![allow(non_snake_case)] -/// Version of this crate (`ooniauth-core`), from `Cargo.toml`. -pub const VERSION: &str = env!("CARGO_PKG_VERSION"); - use cmz::*; use curve25519_dalek::ristretto::RistrettoPoint as G; use group::Group; @@ -19,6 +16,9 @@ pub mod registration; pub mod submit; pub mod update; +/// Version of this crate (`ooniauth-core`), from `Cargo.toml`. +pub const VERSION: &str = env!("CARGO_PKG_VERSION"); + #[derive(Debug, Serialize, Deserialize)] pub struct ServerState { /// The private key for the main User Auth credential From 1a8aeaf8b62aaf27ccdfbc1a9ea797347f18803a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz?= Date: Fri, 3 Apr 2026 12:32:38 +0200 Subject: [PATCH 4/4] Update bindings version --- Cargo.lock | 2 +- ooniauth-py/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4064885..752f326 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1320,7 +1320,7 @@ dependencies = [ [[package]] name = "ooniauth_py" -version = "0.1.2" +version = "0.1.3" dependencies = [ "base64", "bincode", diff --git a/ooniauth-py/Cargo.toml b/ooniauth-py/Cargo.toml index 377de96..e9a52e8 100644 --- a/ooniauth-py/Cargo.toml +++ b/ooniauth-py/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ooniauth_py" -version = "0.1.2" +version = "0.1.3" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html