Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kkohbrok committed Mar 24, 2024
0 parents commit d3b619f
Show file tree
Hide file tree
Showing 13 changed files with 1,263 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

name: REUSE Compliance Check

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

*/target
target
Cargo.lock
.vscode
16 changes: 16 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

[workspace]
members = ["api_client", "types"]
resolver = "2"

[workspace.package]
authors = ["Phoenix R&D <[email protected]>"]
edition = "2021"
license = "AGPL-3.0-or-later"
version = "0.1.0"
homepage = "https://phnx.im"
repository = "https://github.com/phnx-im/minimal-ds-client"
readme = "README.md"
235 changes: 235 additions & 0 deletions LICENSES/AGPL-3.0-or-later.txt

Large diffs are not rendered by default.

156 changes: 156 additions & 0 deletions LICENSES/CC-BY-4.0.txt

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Minimal DS Client

This repository contains a Rust implementation of an API client for a minimal
Delivery Service for use with MLS.

See the module documentation of the `api_client` crate for more information.
17 changes: 17 additions & 0 deletions api_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

[package]
name = "api_client"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
minimal-ds-types = { path = "../types" }
mls-assist = { git = "https://github.com/phnx-im/mls-assist", branch = "konrad/towards_openmls_main" }
reqwest = { version = "0.11" }
openmls = { git = "https://github.com/openmls/openmls" }
thiserror = "1.0"
121 changes: 121 additions & 0 deletions api_client/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

use minimal_ds_types::DsClientIdError;
use openmls::prelude::tls_codec;
use reqwest::StatusCode;
use thiserror::Error;

/// Errors that can occur when sending a message to the DS.
#[derive(Error, Debug)]
pub enum SendMessageError {
#[error(transparent)]
ReqwestError(#[from] reqwest::Error),
#[error("Network error: {0}")]
NetworkError(StatusCode),
#[error("DS error: {0}")]
MinimalDsError(String),
#[error(transparent)]
PayloadSerializationError(#[from] tls_codec::Error),
}

/// Errors that can occur when registering a client with the DS.
#[derive(Error, Debug)]
pub enum RegisterClientError {
#[error("Invalid input : {0}")]
InvalidInput(&'static str),
#[error(transparent)]
InvalidClientId(#[from] DsClientIdError),
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error(transparent)]
RegisterClientError(#[from] SendMessageError),
}

/// Errors that can occur when requesting a list of clients from the DS.
#[derive(Error, Debug)]
pub enum ListClientsError {
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error(transparent)]
RegisterClientError(#[from] SendMessageError),
}

/// Errors that can occur when fetching messages from the DS.
#[derive(Error, Debug)]
pub enum FetchMessagesError {
#[error(transparent)]
FetchMessagesError(#[from] SendMessageError),
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error("Error deserializing response: {0}")]
DeserializationError(#[from] tls_codec::Error),
}

/// Errors that can occur when uploading key packages to the DS.
#[derive(Error, Debug)]
pub enum UploadKeyPackagesError {
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error(transparent)]
UploadKeyPackageError(#[from] SendMessageError),
}

/// Errors that can occur when creating a group on the DS.
#[derive(Error, Debug)]
pub enum CreateGroupError {
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error(transparent)]
CreateGroupError(#[from] SendMessageError),
}

/// Errors that can occur when fetching a key package from the DS.
#[derive(Error, Debug)]
pub enum FetchKeyPackageError {
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error(transparent)]
FetchKeyPackageError(#[from] SendMessageError),
}

/// Errors that can occur when distributing a group message through the DS.
#[derive(Error, Debug)]
pub enum DistributeGroupMessageError {
#[error("Invalid input : {0}")]
InvalidInput(&'static str),
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error(transparent)]
DistributeGroupMessageError(#[from] SendMessageError),
}

/// Errors that can occur when distributing a welcome message through the DS.
#[derive(Error, Debug)]
pub enum DistributeWelcomeError {
#[error("Invalid input : {0}")]
InvalidInput(&'static str),
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error(transparent)]
DistributeWelcomeError(#[from] SendMessageError),
}

/// Errors that can occur when deleting a group on the DS.
#[derive(Error, Debug)]
pub enum DeleteGroupError {
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error(transparent)]
DeleteGroupError(#[from] SendMessageError),
}

/// Errors that can occur when deleting a client from the DS.
#[derive(Error, Debug)]
pub enum DeleteClientError {
#[error("Received an unexpected response.")]
UnexpectedResponse,
#[error(transparent)]
DeleteClientError(#[from] SendMessageError),
}
Loading

0 comments on commit d3b619f

Please sign in to comment.