Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ooniauth-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,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
Expand Down
2 changes: 1 addition & 1 deletion ooniauth-py/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 11 additions & 0 deletions ooniauth-py/ooniauth_py.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import builtins
import typing

__version__: builtins.str

class CredentialError(builtins.Exception):
r"""
An authentication error
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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: ...
Expand All @@ -80,13 +84,20 @@ 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.

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.
"""
4 changes: 4 additions & 0 deletions ooniauth-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ 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_function(wrap_pyfunction!(get_protocol_version, m)?)?;
m.add_class::<ServerState>()?;
m.add_class::<UserState>()?;
m.add_class::<SubmitRequest>()?;
Expand Down
9 changes: 8 additions & 1 deletion ooniauth-py/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading